CodechefMay 23, 2025

X Jumps

Hazrat Ali

Codechef

Chef is currently standing at stair 0 and he wants to reach stair numbered XX.

Chef can climb either YY steps or 11 step in one move.
Find the minimum number of moves required by him to reach exactly the stair numbered XX.

Input Format

  • The first line of input will contain a single integer TT, denoting the number of test cases.
  • Each test case consists of a single line of input containing two space separated integers XX and YY denoting the number of stair Chef wants to reach and the number of stairs he can climb in one move.

Output Format

For each test case, output the minimum number of moves required by him to reach exactly the stair numbered XX.

Constraints

  • 1≤T≤500
  • 1≤X,Y≤100

Sample 1:

Input
4
4 2
8 3
3 4
2 1
Output
2
4
3
2

Solution
for _ in range(int(input())):
    x,y=map(int,input().split())
    if x%y==0:
        print(int(x/y))
    elif x<y:
        print(x)
    else:
        s=int(x/y)
        print(s+(x-s*y))


 

Comments