Please Help in 'misha and nice set' problem

This is the code in python for CodeChef: Practical coding for everyone
misha and nice set.PLease help me to debug.i can’t find any problem in my solution.Please help me.
import math
t=int(input())
while(t>0):
n=input().split()
l=int(n[0])
r=int(n[1])
g=int(n[2])
if(l>r):
print(0)
else:
if(g>r):
print(0)
if(g>=l and g<=r):
x=r//g
print(x)
if(g<l):
m=math.ceil(l/g)
y=r//g
if((y-m+1)==1):
print(0)
else:
print(y-m+1)
t=t-1

Check these test cases
6
3 4 3
6 7 3
2 10 3
3 10 3
2 9 3
3 9 3

Answers are
1
0
3
3
3
3
Ping me if you need more test cases

1 Like

yeah…
6

3 4 3
1

6 7 3
0

2 10 3
3

3 10 3
3

2 9 3
3

3 9 3
3
i think the inbuilt ceil() of python is giving error…

1 Like

N
I can’t understand if i use a simple loop to calculate the answer…why it is saying “WRONG ANSWER”

check this one
1
6 7 3
0
may be your code is giving 1 instead of 0…

Sorry I haven’t seen that only ‘r’ is inclusive.
But even after making change in line no12… for(j=l+1;j<=r;j++)
still it says WRONG answer…
Can you help once more ?

Nope l,r both are inclusive… but you need to add one condition
If(ans==1 && l>g)
ans=0;
Cuz gcd {6} = {6} not 3