sgarden[wrong answer]

here is ideone link to my code http://ideone.com/mAApey
Please point out where I’m wrong.
My approach is a bit different.
This is the new link(with all explainations) http://ideone.com/1Wq2aS
My code runs for all the test cases I can think of.

first problem is in finding LCM using gcd and modulo,

use prime factorisation!
see the second answer to the sgarden editorial .
PS editorial and replies to it first :slight_smile: .
Upvote if it helped

1 Like

Its difficult to understand your code. So,I suggest you to please put some comment and explanation so that we can go through your code…