I am trying to solve GARDEN GAME problem
first i am trying to find length of cycles using concept similar in PCYCLE
then i am making an array containing maximum powers of all prime factors of lengths of cycles to calculate LCM as mentioned in GARDEN GAME EDITORIAL
my code is giving right answer for the test cases i have tried
yet it is giving WA after submiting
THIS IS MY CODE
Please help
-
What is use of the loop that has the array a[]?
I don’t think there is any use of this while loop.
So, remove it.
-
Also, you are not taking (lcm)%1000000007 at each step.
-
There were also many small errors like use of %d instead of %lld for long long in scanf().
-
Your algorithm for finding the factors was also very complex. I changed it.
-
Try to correct your code for factors() function.
-
You are declaring max as global. This needs to inside while(t–) loop so that it is initially zero for all test cases.
-
There is no need to use pow function, a simple for loop will work.
I have corrected your code: Click Here
1 Like
Thanks a lot for going through my code.
and providing me such a detail analysis of my code and silly mistakes.
Learnt a lot
thanks.