here is ideone link to my code mAApey - Online C++ Compiler & Debugging Tool - Ideone.com
Please point out where I’m wrong.
My approach is a bit different.
This is the new link(with all explainations) 1Wq2aS - Online C++ Compiler & Debugging Tool - Ideone.com
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 .
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…