Cycles finding is similar to this : PCYCLE Problem - CodeChef
java biginteger is really useful
use prime factorization to find LCM.
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)
you need to do inverse to calc division modulo
another good editorial, which was written during the contest: combinatorics - Count the whistles - Mathematics Stack Exchange
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 modular arithmetic - Very simple question, but what is the proof that x.y mod m == ((x mod m).y) mod m? - Mathematics Stack Exchange