It seemed an easy problem. I even took care of edge cases I think. I don't know why I'm getting WA. Will the submissions be made public? asked 31 Dec '18, 00:18

You are not considering the probability of overflow in lcm. I also got a wrong answer verdict for the same condition. My accepted solution link is Solution Link answered 31 Dec '18, 12:55
it was not what you said but it had to do with the lcm! I use ceil function in the code and when lcm got very very large, ceil(1/lcm), which i expected to give 1, gave 0. thanks!
(31 Dec '18, 23:55)
got AC! thanks.
(01 Jan, 00:05)

Your solution is giving WA on corner case. Here it is :https://ideone.com/mwfrVA The correct answer is +1. answered 31 Dec '18, 19:24
sorry, your link is private(it says "forbidden"). could you please make a public link or tell me the testcase here?
(31 Dec '18, 23:23)
It is working now. Sorry for inconvenience. :)
(01 Jan, 01:24)
Thanks. By the way, could you please tell how did you find this case? Did you have access to the cases, did you generate cases specifically for this problem or is there some tool I am unaware of?
(01 Jan, 15:16)
I just tried to generate the worst case. I just needed to find when n and m both are zero. In such cases, your code would have been failed. And I don't have access to test cases. I generated this specifically for this question after seeing your post. :)
(01 Jan, 20:52)
