crazy-kangaroo

Little Jhool is a world renowned  kangaroo trainer. He's now living in Australia, and is training kangaroos for his research project on mobile soccer. (We don't know the connection, too.) Anyway, for the project to be completed he observes kangaroos for a lot of time - because he wants to figure out the hop count for various kangaroos he's training.

Now, he makes a kangaroo stand at the starting point, and lets him jump to the finishing point - given the hop count 
of that  particular kangaroo, figure out the number of jumps he would take between the starting point to the ending point. Both the starting point and the ending points are inclusive.

Note: He will jump only to those positions which are multiples of M or hop count.

Input:
First line contains number of test cases T. Next T lines contains three integers A, B and M separated by single space.  A denoted the starting point, B the finishing point - and M, the hop count - the distance covered by that kangaroo in one jump.

Output: 
For each test case print the number of jumps the kangaroo had to make in the range [A, B] inclusive.  

Constraints:
1 ≤ T ≤ 100000
1 ≤ A ≤ B ≤ 10^12
1 ≤ M ≤ 10^12

SAMPLE INPUT
3
1 10 2
5 10 3
7 9 5SAMPLE OUTPUT
5
2
0

Explanation

Test Case #1:
There are 5 multiples of 2 that are {2,4,6,8,10} in range [1,10] .    

Test Case#2:
There are 2 multiples of 3  that are {6,9} in range [5,10] .  

Test Case#3:
There are no any multiple of 5 is there in range [7,9].

Source: hackerearth | Difficulty: EASY
Tags: Fundamentals

Mathematics

Ad-hoc


Solutions:
'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())
while(t):
	a=list(map(int,input().split()))
	A=a[0]
	B=a[1]
	M=a[2]
	print(((B/M)-(A-1)/M))
	t-=1


#!/usr/bin/python
import math        

'''
http://math.stackexchange.com/questions/211445/how-many-multiples-of-x-lie-in-the-arbitrary-range-y-z
'''

TestCases = int(input())
if 1 <= TestCases <= 100000:
	for i in range(TestCases):
		#1000000000000
		s = input()
		n = list(map(float, s.split()))
		print(int(max(math.floor(n[1]/n[2])-math.ceil(n[0]/n[2])+1,0)))
		#print int((n[1]/n[2])-(n[0]-1)/n[2])


t = int(input())
for _ in range(t):
	a = list(map(int,input().split()))
	
	cnt = (a[1] - a[0] + 1)/a[2]
	y = (a[1] - a[0] + 1) % a[2]
	z = a[1] % a[2]
	if y > z:
		cnt += 1
	print(cnt)


number = int(input())
while(number):
	a,b,m = input().split(" ")

	a = int(a)
	b = int(b) 
	m = int(m)
	print(b/m - (a-1)/m)

	number -= 1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

def hop ():
	for T in range (eval(input ())):
		A, B, M = list(map (int, input ().split ()))
		result = B/M - (A-1)/M
		print(result)
if __name__ == "__main__":
	hop ()
		


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
def get_total_jump(A, B, M):
	count = 0
	#for i  in range(A, B + 1):
	#    if i % M == 0:
	#       count += 1
	return (B/M - (A-1)/M)
	
test_cases = eval(input())
for i in range(test_cases):
	a, b, m = list(map(int, input().split()))
	print((get_total_jump(a, b, m)))


#!/usr/bin/python
import math        
TestCases = int(input())
if 1 <= TestCases <= 100000:
	for i in range(TestCases):
		#1000000000000
		s = input()
		n = list(map(float, s.split()))
		print(int(max(math.floor(n[1]/n[2])-math.ceil(n[0]/n[2])+1,0)))


t=int(input())
for i in range(t):
	a,b,m=list(map(int,input().split()))
	print(b/m-(a-1)/m)


for _ in range(eval(input())):
	start , end, jump = list(map(int, input().split()))    
	print((end / jump  - (start -1) / jump))


tc = int(input())
while (tc>0):
	tc = tc - 1
	a, b, m = list(map(int, input().split()))
	print((b/m)-(a-1)/m)


t = int(input())
while(t):
	cnt = 0
	a,b,m = list(map(int,input().split()))
	if(a>b):
		a,b = b,a
	print((b/m-(a-1)/m))
	t-=1


tc=int(input())
while tc:
	a,b,m=list(map(int,input().split()))
	print((b/m)-(a-1)/m)
	tc=tc-1







m=eval(input())
for i in range(m):
	a,b,c=list(map(int,input().split()))
	d=b/c-(a-1)/c
	print(d)
	
	
			


T = eval(input())
for i in range(T):
	A,B,M = (int(i) for i in input().split())
	
	
	print((B/M)-((A-1)/M)) 
	
		


t=eval(input())
while t:
	a,b,m=list(map(int,input().split()))
       
	print((b/m)-(a-1)/m)
	t-=1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
count = int(input())

for i in range(count):
	val = list(map(int, input().split(" ")))
	B = val[1]
	A = val[0]
	M = val[2]
	
	print((B/M)-(A-1)/M)


import sys
t=eval(input())
while(t):
	t-=1
	a,b,m=list(map(int,sys.stdin.readline().split()))
	if(a>b):
		print(((a/m)-(b-1)/m))
	else:
		print(((b/m)-(a-1)/m))


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
i = input()

for ti in range(int(i)):
	in_str = input()
	lis = str(in_str).split(' ')
	a = int(lis[0])
	b = int(lis[1])
	m = int(lis[2])
	ans = 0
	if a%m != 0:
		a = a+m-(a%m)
	if b%m != 0:
		b -= (b%m)
	if b > a:
		ans = ((b-a)/m)+1
	print(ans)	
		


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
import math

T = int(input())

for step in range(T):
	
	A,B,M = list(map(int, input().split()))
	
	hop =  (B/M)-((A-1)/M)
	
	print(hop)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''

t=eval(input())
c=0
while(t):
	a,b,m=list(map(int,input().split()))
	if(a>b):
		a,b=b,a
	print((b/m-(a-1)/m))
	t=t-1


for _ in range (eval(input())):
	n,m,t=list(map(int,input().split()))
	d=m/t-(n-1)/t
	print(d)


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())
while(t>0):
	c=0
	data=list(map(int,input().split()))
	a=data[0]
	b=data[1]
	m=data[2]
	if(b>=a):
		c= (b/m) - ((a-1)/m)
	print(c)
	t-=1


test_cases = int ( input () )
for i in range ( 0, test_cases ) :
	start, end, hop = input ().split ()
	start = int ( start )
	end = int ( end )
	hop = int ( hop )
	count = 0
	if ( hop <= end ) :
		if start <= hop : start = hop
		else :
			if start % hop != 0 :
				start = ( ( start / hop ) + 1 ) * hop
		count = ( end / hop ) - ( start / hop ) + 1
	print(count)


import sys

t= int(eval(input()))
while t>0:
	jump=0
	t=t-1
	line= input().split(' ')
	a= int(line[0])
	b= int(line[1])
	m= int(line[2])
	a=a-1
	jump= abs(int(b/m)-int(a/m))
	print(jump)
		


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
#print 'Hello World!'
t=int(input())
while(t):
	l=list(map(int,input().split()))
	A=l[0]
	B=l[1]
	C=l[2]
	print(((B/C)-(A-1)/C))
	t-=1
	
	


n = input()
n = int(n)
for i in range(n):
	s_tmp = input()
	s_tmp = s_tmp.split(" ")
	a = int(s_tmp[0])
	b = int(s_tmp[1])
	m = int(s_tmp[2])

	ans = 0
	if a % m != 0:
		a = a + m-(a % m)
	if b % m != 0:
		b -= (b % m)
	if b > a:
		ans = ((b-a)/m)+1
	print(ans)


tc = int(input())
assert(tc >= 1 and tc <= 100000)

for i in range(tc):
	a, b, m = list(map(int, input().split()))
	print(b/m - (a-1)/m)



T=eval(input())
while (T>0):
	a=input().split()
	n1=int(a[0])
	n2=int(a[1])
	m=int(a[2])
	count=(n2/m)-(n1/m)
	if(n1%m==0):
		count+=1
		
	print(count)
	T-=1


'''
# Read input from stdin and provide input before running code

name = raw_input('What is your name?\n')
print 'Hi, %s.' % name
'''
t=int(input())
for i in range(t):
	count=0
	n=list(map(int,input().split()))
	a=n[0]%n[2]
	c=n[1]%n[2]
	if a==0:
		b=n[0]
	else:
		b=n[0]+n[2]-a
	if c==0:
		d=n[1]
	else:
		d=n[1]-c
	count=(d-b)/n[2]
	print(count+1)


t=int(input())
while(t>0):
    
	a,b,m=input().split(" ")
	a,b,m=int(a),int(b),int(m)
	c=b/m-(a-1)/m
	print(c)
	t-=1    


import re
a = int(input())

def fx(a,b,c):
	if a%c==0:print((b-(a-a%c))/c +1)
	else : print((b-(a-a%c))/c) 
while a>0:
	a = a -1 
	b = input()
	c = re.findall('[\d]+',b)
	d = [int(x) for x in c]
	fx(d[0],d[1],d[2])



t=eval(input())
while t>0:
	t-=1
	a,b,m =list(map(int, input().split()))
	print((b-(a-a%m))/m + (1 if a%m==0 else 0))