Chef is standing at coordinate A while Chefina is standing at coordinate B.

In one step, Chef can increase or decrease his coordinate by at most K.

Determine the minimum number of steps required by Chef to reach Chefina.

------ Input Format ------ 

- The first line of input will contain a single integer T, denoting the number of test cases.
- Each test case consists of three integers X, Y, and K, the initial coordinate of Chef, the initial coordinate of Chefina and the maximum number of coordinates Chef can move in one step.

------ Output Format ------ 

For each test case, output the minimum number of steps required by Chef to reach Chefina.

------ Constraints ------ 

$1 ≤ T ≤ 1000$
$1 ≤ X, Y ≤ 100$
$1 ≤ K ≤ 100$

----- Sample Input 1 ------ 
4
10 20 3
36 36 5
50 4 100
30 4 2

----- Sample Output 1 ------ 
4
0
1
13

----- explanation 1 ------ 
Test case $1$: In the first three steps, Chef increases his coordinate by $K = 3$. In the fourth step, Chef increases his coordinate by $1$ which is less than equal to $K$. It can be shown that this is the minimum number of steps required by Chef.

Test case $2$: Chef is already at the same coordinate as Chefina. Thus, he needs $0$ steps.

Test case $3$: Chef can use $1$ step to decrease his coordinate by $46$ which is less than $K = 100$ and reach Chefina.

Test case $4$: Chef can use $13$ steps to decrease his coordinate by $K = 2$ and reach the coordinate $30-13\cdot 2 = 4$.

Difficulty: EASY
Tags: Mathematics

Starter code:

Solutions:
T = int(input())
for tc in range(T):
	(x, y, k) = map(int, input().split(' '))
	diff = abs(y - x)
	move = diff // k
	if diff % k > 0:
		move += 1
	print(move)


T = int(input())
for i in range(0, T):
	(x, y, k) = map(int, input().split())
	temp = abs(x - y)
	if temp % k == 0:
		print(temp // k)
	else:
		print(temp // k + 1)


for i in range(int(input())):
	(X, Y, K) = map(int, input().split())
	if abs(Y - X) % K == 0:
		print(abs(Y - X) // K)
	else:
		print(abs(Y - X) // K + 1)


import math
for i in range(int(input())):
	(x, y, k) = map(int, input().split())
	count = 0
	if y > x:
		diff = y - x
		count = math.ceil(diff / k)
	elif x > y:
		diff = x - y
		count = math.ceil(diff / k)
	print(count)


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	diff = abs(x - y)
	if diff == 0:
		print(0)
	elif diff % k == 0:
		print(diff // k)
	else:
		print(diff // k + 1)


import math
for j in range(int(input())):
	(x, y, k) = map(int, input().split())
	a = abs(x - y)
	if x - y == 0:
		print(0)
	else:
		print(math.ceil(a / k))


from math import ceil
for _ in range(int(input())):
	(chef, chefina, max_per_step) = map(int, input().split())
	distance = abs(chef - chefina)
	print(ceil(distance / max_per_step))


import math
for i in range(int(input())):
	(x, y, k) = map(int, input().split())
	z = abs(y - x)
	print(math.ceil(z / k))


import math
for _ in range(int(input())):
	(x, y, k) = map(int, input().split())
	x1 = abs(x - y)
	x2 = x1 // k
	x3 = x1 % k
	if x3 % k > 0:
		x2 += 1
	print(x2)


import math
t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split(' '))
	a = math.ceil(abs(x - y) / z)
	print(a)


for i in range(int(input())):
	(x, y, z) = map(int, input().split())
	if x - y == 0:
		print(0)
	elif abs(x - y) % z == 0:
		print(abs(x - y) // z)
	else:
		print(abs(x - y) // z + 1)


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	count = 0
	if x < y:
		while x < y:
			x += k
			count += 1
		print(count)
	elif x > y:
		while x > y:
			x -= k
			count += 1
		print(count)
	else:
		print(0)


t = int(input())
import math
for i in range(t):
	(n, k, s) = map(int, input().split())
	print(math.ceil(abs(n - k) / s))


T = int(input())
for i in range(T):
	x = list(map(int, input().split()))
	X = x[0]
	Y = x[1]
	K = x[2]
	m = abs(X - Y)
	if m == 0:
		print('0')
	else:
		steps = m / K
		if round(steps) > steps:
			print(round(steps))
		elif round(steps) < steps:
			print(round(steps) + 1)
		else:
			print(int(steps))


import math
t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	s = abs(x - y) / k
	print(math.ceil(s))


t = int(input())
for i in range(t):
	(a, b, k) = map(int, input().split(' '))
	z = b - a
	if z < 0:
		z = -z
	if z == 0:
		print(z)
	else:
		if z % k == 0:
			z1 = int(z / k)
		else:
			z1 = int(z / k) + 1
		print(z1)


x = int(input())
for i in range(x):
	(m, n, k) = input().split()
	m = int(m)
	n = int(n)
	k = int(k)
	if n > m:
		l = n - m
	else:
		l = m - n
	if l % k == 0:
		print(l // k)
	else:
		print(l // k + 1)


import math
for _ in range(int(input())):
	(x, y, k) = map(int, input().split())
	print(math.ceil(abs(x - y) / k))


t = int(input())
for i in range(t):
	(a, b, c) = map(int, input().split())
	if (a - b) % c == 0:
		print(abs(a - b) // c)
	else:
		print(abs(a - b) // c + 1)


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	b = min(x, y)
	c = max(x, y)
	a = c - b
	if a % k == 0:
		print(a // k)
	else:
		print(a // k + 1)


for i in range(int(input())):
	(x, y, k) = map(int, input().split())
	if x == y:
		print(0)
	elif x < y and (y - x) % k == 0:
		s = (y - x) / k
		print(int(s))
	elif x < y and (y - x) % k != 0:
		s = (y - x) / k + 1
		print(int(s))
	elif x > y and (x - y) / k == 0 or (x - y) / k == 1:
		print(1)
	elif x > y and (x - y) % k != 0:
		print(int((x - y) / k) + 1)
	else:
		s = (x - y) / k
		print(int(s))


n = int(input())
for i in range(n):
	(a, b, c) = map(int, input().split())
	sub = abs(b - a)
	m = sub // c
	if sub % c > 0:
		m += 1
	print(m)


a = int(input())
for i in range(a):
	(x, y, k) = map(int, input().split())
	d = abs(x - y)
	s = d // k
	if d % k > 0:
		s += 1
	print(s)


import math
t = int(input())
while t > 0:
	(x, y, k) = map(int, input().split())
	dif = abs(x - y)
	steps = dif / k
	p = math.ceil(steps)
	print(p)
	t -= 1


t = int(input())
for i in range(t):
	(x, y, k) = input().split()
	x = int(x)
	y = int(y)
	k = int(k)
	if x > y:
		z = (x - y) % k
		if z == 0:
			l = (x - y) // k
			print(l)
		else:
			l = (x - y) // k + 1
			print(l)
	else:
		z = (y - x) % k
		if z == 0:
			l = (y - x) // k
			print(l)
		else:
			l = (y - x) // k + 1
			print(l)


for _ in range(int(input())):
	(x, y, z) = list(map(int, input().split()))
	count = 0
	if x < y:
		while True:
			x = x + z
			count = count + 1
			if x >= y:
				break
	elif x > y:
		while True:
			x = x - z
			count = count + 1
			if x <= y:
				break
	else:
		count = 0
	print(count)


T = int(input())
for i in range(T):
	(x, y, k) = map(int, input().split(' '))
	d = abs(y - x)
	move = d // k
	if d % k > 0:
		move += 1
	print(move)


import math
t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	c = abs(x - y)
	if c == 0:
		print(0)
	elif c <= k:
		print(1)
	elif c % k == 0:
		print(c // k)
	else:
		print(math.ceil(c / k))


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	j = 0
	while True:
		if abs(x - y) <= j * k:
			break
		j += 1
	print(j)


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	distance = abs(x - y)
	steps = distance // k
	if distance % k == 0:
		print(steps)
	else:
		print(steps + 1)


for i in range(int(input())):
	(a, b, c) = map(int, input().split())
	v = abs(a - b)
	if v / c == v // c:
		print(v // c)
	else:
		print(v // c + 1)


import math
T = int(input())
for i in range(T):
	(X, Y, K) = map(int, input().split(' '))
	print(math.ceil(abs((X - Y) / K)))


import math as m
n = int(input())
for i in range(n):
	(x, y, k) = map(int, input().split())
	c = m.ceil(abs((y - x) / k))
	print(c)


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	d = abs(x - y) % k
	e = abs(x - y) // k
	if d == 0:
		print(e)
	else:
		print(e + 1)


n = int(input())
for i in range(n):
	(a, b, c) = list(map(int, input().split()))
	c1 = 0
	if a < b:
		while a < b:
			c1 = c1 + 1
			a = a + c
	elif a == b:
		c1 = 0
	elif a > b:
		while a > b:
			c1 = c1 + 1
			a = a - c
	print(c1)


for _ in range(int(input())):
	(x, y, k) = map(int, input().split())
	dist = abs(y - x)
	if dist % k == 0:
		print(dist // k)
	else:
		print(dist // k + 1)


t = int(input())
for i in range(t):
	(n, k, x) = map(int, input().split())
	s = abs(n - k)
	if s % x == 0:
		print(s // x)
	else:
		print(s // x + 1)


import math
for i in range(int(input())):
	(a, b, k) = map(int, input().split())
	c = b - a
	print(math.ceil(abs(c) / k))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	if abs(a - b) % c == 0:
		print(abs(a - b) // c)
	else:
		print(1 + abs(a - b) // c)


q = int(input())
for i in range(q):
	(x, y, k) = map(int, input().split())
	if abs(x - y) % k == 0:
		a = 0
	else:
		a = 1
	print(abs(x - y) // k + a)


import math
for t in range(int(input())):
	(x, y, k) = map(int, input().split())
	cor = abs(y - x)
	print(math.ceil(cor / k))


import math
a = int(input())
for i in range(a):
	b = [int(x) for x in input().split()]
	if b[0] == b[1]:
		print(0)
	else:
		c = b[0] - b[1]
		c = abs(c)
		print(math.ceil(c / b[2]))


t = int(input())
for i in range(t):
	(x, y, z) = map(int, input().split())
	diff = abs(x - y)
	move = diff // z
	if diff % z > 0:
		move += 1
	print(move)


t = int(input())
for i in range(t):
	(x, y, k) = map(int, input().split())
	p = abs(y - x)
	move = p // k
	if p % k > 0:
		move += 1
	print(move)


import math
T = int(input())
for _ in range(T):
	(X, Y, K) = map(int, input().split())
	min_steps = math.ceil(abs(X - Y) / K)
	print(min_steps)


for i in range(int(input())):
	(x, y, k) = map(int, input().split())
	if x == y:
		print(0)
	elif x > y:
		d = x - y
		if d % k == 0:
			print(int(d / k))
		else:
			print(int(d / k) + 1)
	else:
		d = y - x
		if d % k == 0:
			print(int(d / k))
		else:
			print(int(d / k) + 1)


for t in range(int(input())):
	(x, y, k) = list(map(int, input().split()))
	d = abs(y - x)
	m = d // k
	if d % k > 0:
		m += 1
	print(m)


T = int(input())
for i in range(T):
	(x, y, k) = map(int, input().split(' '))
	diff = abs(y - x)
	steps = diff // k
	if diff % k > 0:
		steps += 1
	print(steps)


for _ in range(int(input())):
	(x, y, z) = list(map(int, input().split()))
	p = abs(y - x)
	k = p // z
	if p % z > 0:
		k += 1
	print(k)


import math as m
for _ in range(int(input())):
	(x, y, z) = map(int, input().split())
	print(m.ceil(abs(x - y) / z))


for _ in range(int(input())):
	(a, b, c) = map(int, input().split())
	dif = abs(b - a)
	res = dif // c
	if dif % c > 0:
		res += 1
	print(res)


t = int(input())
for i in range(t):
	x_y_k = input().split(' ')
	(x, y, k) = (int(x_y_k[0]), int(x_y_k[1]), int(x_y_k[2]))
	if x == y:
		print(0)
	elif abs(x - y) % k == 0:
		print(abs(x - y) // k)
	else:
		print(abs(x - y) // k + 1)