By mufaddalnaya, history, 5 months ago, ,

In the latest codeforces Div. 3 contest, my solution for problem D is getting time limit exceeded. The code is written in java and I couldn't figure out the reason. The Problem and my 54157908. I saw some other java code which are accepted that have similar time complexity as my code.

• 0

 » 5 months ago, # |   0 Not quite sure, but am assuming that the problem is with the long division here: for(int i=0;i
•  » » 5 months ago, # ^ |   0 Actually the problem was that I was using the gcd function due to which i would get a huge number at the end may be 10^18 and then i was trying to check all its divisors and therefore getting time limit exceeded.
•  » » » 5 months ago, # ^ |   0 Interesting, I didn't think that might happen as the gcd function takes O(logn) time. Oh well, thanks for the info ^^