Going wrong on test case 2 on code forces


problem
https://codeforces.com/contest/1342/problem/C

@coe17b014,
You should check out the editorial of the problem.

can u tell me where my code is going wrong??

@coe17b014,
I think there’s something wrong with your logic, the problem is based on lcm, and I don’t see lcm anywhere in your code.

it is a*b not lcm (a,b)

@coe17b014,
Please explain your logic for the problem.

create an array of size a*b.
keep the count of numbers which satisfy the i%A)%B!=i%B)%A
find the no of such number from 0 to l…and 0 to r and subtract each other

bro i just wrote a new code

this is also wrong anser on test case 2

@coe17b014,
If counting (i%A)%B!=(i%B)%A works, than why didn’t you just count (i%A)%B==(i%B)%A instead…??
I think there is something wrong with your logic, you should rather consider the approach suggested in editorial, it is actually a beautiful way of doing this problem.

I submitted it yesterday and got it accepted bro.i am doing indexing error.thanks for the help

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.