SGARDEN - Editorial

Cycles finding is similar to this : http://www.codechef.com/problems/PCYCLE

1 Like

java biginteger is really useful :smiley: :stuck_out_tongue:

3 Likes

use prime factorization to find LCM.

1 Like

Won’t taking mod each time give the wrong answer?

3 Likes

Hi All , The last pseudo code is wrong and is mentioned above . Even the function name “Wrong_Solution” suggests that it is wrong!

slow logic and the use of swap function is making it slower
and ur using brute force…think of some other logic

one mistake which I found is overflow in variable x .There may or may not be other mistakes.

(x/y)%z != (x%z)/(y%z)

1 Like

you need to do inverse to calc division modulo

another good editorial, which was written during the contest: http://math.stackexchange.com/questions/856302/count-the-whistles

Hey, @devuy11, the error in the pseudo code wrong_soltion
http://discuss.codechef.com/questions/47443/lcm-of-n-numbers-modulo-1097

This was not very obvious to me. (x.y)modm==((xmodm).y)modm http://math.stackexchange.com/questions/5366/very-simple-question-but-what-is-the-proof-that-x-y-mod-m-x-mod-m-y-mod?rq=1