Comments

Thanks. The changes I did were removed memset(prefix , 0 , sizeof prefix); and did prefix[0] = 0; But it will still give TLE. I then made int exist[1000000+1]; to bool exist[1000000+1]; which passed.

I still don't understand why changing exist from int to bool got me AC.I know bool takes less memory and is faster than int, but is the difference significant enough to give TLE??

Can someone explain why I am getting TLE in div2 D prob https://codeforces.com/contest/1649/submission/148733037

n can be of the form 4*k , 4*k+1 , 4*k+2 , 4*k+3 (for some k>=0) case 1: n = 4*k ans = k ,k, 2*k LCM = 2*k

case 2: n = 4*k+1 ans = 1 ,2k ,2k LCM = 2k

case 3: n= 4*k+2 ans = 2 , 2k , 2k LCM = 2k

case 4: n = 4k+3 ans = 1 , 2k+1 , 2k+1 LCM = 2k+1

How this submission is getting accepted and not TLE as clearly their is a for loop that goes till 'n' and 'n' is 10^9 and test cases 't'= 1000. and time limit is 1 sec. Link: https://codeforces.com/contest/1476/submission/105860386 I thought in 1 sec only 10^9 operations can be done

very useful!!!!