Problem
You have Apples.You can eat apples on a single day.What's the minimum number of days required to eat all apples?
Input Format
- The first line of the input contains a single integer denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains two space-separated integers .
Output Format
For each test case, print a single line containing one integer - the minimum number of days required to eat all apples.
Constraints
Sample 1:
3 3 3 3 2
1 2
Explanation:
Test case 1: Since and ,it requires only day to eat all apples.
Test case 2: We have and , it require a minimum of days to eat all apples.
Program :
import java.util.*;
class Main
{
public static void main (String[] args)
{
int t,i,a,b,c,d;
Scanner es=new Scanner(System.in);
t=es.nextInt();
for(i=0;i<t;i++)
{
a=es.nextInt();
b=es.nextInt();
if(a==b)
{
System.out.println("1");
}
else if(a%b==0)
{
d=a/b;
System.out.println(d);
}
else if(a%b!=0)
{
d=a/b+1;
System.out.println(d);
}
}
}
}
0 Comments