304 North Cardinal St.
Dorchester Center, MA 02124

# X Jumps CodeChef Solution

## Problem – X Jumps CodeChef Solution

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

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

#### Input Format

• The first line of input will contain a single integer T, denoting the number of test cases.
• Each test case consists of a single line of input containing two space separated integers X and Y 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 X.

#### Constraints

• 1≤T≤10
• 1 \leq A \lt B \lt C \leq 101≤A<B<C≤10

#### Sample 1:

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

#### Explanation:

Test case 1: Chef can make 2 moves and climb 2 steps in each move to reach stair numbered 4.

Test case 2: Chef can make a minimum of 4 moves. He can climb 3 steps in 2 of those moves and 1 step each in remaining 2 moves to reach stair numbered 8.

Test case 3: Chef can make 3 moves and climb 1 step in each move to reach stair numbered 3.

Test case 4: Chef can make 2 moves and climb 1 step in each move to reach stair numbered 2

### X Jumps CodeChef Solution in Python3

# cook your dish here
t=int(input())
for i in range(t):
x,y=map(int,input().split())
if x%y==0:
print(x//y)
elif x%y==1:
print(x//y + 1)
else:
print(x//y + x-(x//y)*y)


### X Jumps CodeChef Solution in C++17

#include <iostream>
using namespace std;

int main() {
int t;
cin>>t;
for(int i=0;i<t;i++)
{
int x , y , z;
int temp;
cin>>x>>y;
temp=x;
z=x/y;
z+=temp%y;
cout<<z<<endl;

}
return 0;
}

### X Jumps CodeChef Solution in Java

/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner sc=new Scanner(System.in);
int t=sc.nextInt();
while(t>0)
{
int a=sc.nextInt();
int b=sc.nextInt();
if(a<b)
{
System.out.println(a);

}
else if(a%b==0)
{
System.out.println(a/b);
}
else{
System.out.println((a/b)+(a%b));

}
t--;
}

}
}
##### X Jumps CodeChef Solution Review:

In our experience, we suggest you solve this X Jumps CodeChef Solution and gain some new skills from Professionals completely free and we assure you will be worth it.

If you are stuck anywhere between any coding problem, just visit Queslers to get the X Jumps CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this X Jumps CodeChef Solution would be useful for you to learn something new from this problem. If it helped you then don’t forget to bookmark our site for more Coding Solutions.

This Problem is intended for audiences of all experiences who are interested in learning about Data Science in a business context; there are no prerequisites.

Keep Learning!

More Coding Solutions >>

LeetCode Solutions

Hacker Rank Solutions

CodeChef Solutions