I know my time limit is exceeding but still can someone pls tell me why my code is not working??

you have sent the submit page. This doesnot show us your code.
Go to the problem page, click my solutions, click view on the solution you want help with, and then copy the link from address bar and paste it here.

1 Like

Either way, i did look up your solution, and here is what you were doing wrong.
you made a loop from the lower number to 10^7(why?).
if you look at the answer of the sample test case, you can see that the answer is greater than 10^7.
so clearly that is what you were doing wrong.
you need to make the loop run upto ab+1, since no matter what, ab will always be divisible by a and b both.
the reason you were even getting an answer there is because you made the variables outside the loops, and didnot assign them a 0 inside. What this did was it didnot remove the old values after the loop had finished. So your answer was from the previous inputs on which it ran, and not the ones it was currently running on(in case the LCM exceeded 10^7).
Here is your code but corrected : CodeChef: Practical coding for everyone
Still a TLE, so see how you can fix that :slight_smile:
Hope this helps,
Happy coding :slight_smile:

oh and what he said, please dont re-post

Thanks buddy , problem solved but still i have to take care of time complexity.