SGARDEN - Editorial

Cycles finding is similar to this :

1 Like

java biginteger is really useful :smiley: :stuck_out_tongue:


use prime factorization to find LCM.

1 Like

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


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:

Hey, @devuy11, the error in the pseudo code wrong_soltion

This was not very obvious to me. (x.y)modm==((xmodm).y)modm