Getting wrong answer

I am doing this question from codeforces…
https://codeforces.com/contest/573/problem/A
My approch is first i am calculating lcm of the array.
Now after this i am dividing the lcm with each number we of array… the result we get after division…let’s say x.
Now i am checking…if x contain any factor other than 2 and 3… then we will say No…
otherwise we got to next element of array and repeat the process.
This is my solution…
But it is showing wrong answer on test-case 18…
https://codeforces.com/contest/573/submission/97989108
Please see this where my code is failing.
Thanks

Hey @ashishnnnnn

2 ≤ n ≤ 105
Now assume I give u all the prime numbers possible with some random number remaining ,So will u be able to hold its LCM in any variable :slight_smile:
Now think of another approach.

I have come with some other approch…
But this is giving tle–on test case 47…
https://codeforces.com/contest/573/submission/97993890
:slight_smile:

Please explain ur approach :slight_smile:

Actually… I found the right approch… No need to do this much…

1 Like

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.