Apple and Day: APPDAY
Apple and Day APPDAY codechef solution in C, C++, JAVA, Python
CU Submission link: Click here (need login by CU account)
You have NN Apples. You can eat KK 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 TT denoting the number of test cases. The description of TT test cases follows.
- The first and only line of each test case contains two space-separated integers N,KN,K.
Output Format
For each test case, print a single line containing one integer – the minimum number of days required to eat all apples.
Constraints
- 1≤T≤1041≤T≤104
- 1≤N≤1021≤N≤102
- 1≤K≤1021≤K≤102
Sample Input 1
3
3 3
3 2
Sample Output 1
1
2
Explanation
Test case 1: Since K=3K=3 and N=3N=3,it requires only 11 day to eat all apples.
Test case 2: We have K=2K=2 and N=3>KN=3>K, it require a minimum of 22 days to eat all apples.
Apple and Day APPDAY Codechef Solution in C
// dont forget to include header files
int main(void) {
int t;
scanf("%d",&t);
while(t--)
{
int a,b;
scanf("%d %d",&a,&b);
if(a%b==0)
printf("%d \n",a/b);
else
printf("%d\n",(a/b)+1);
}
return 0;
}
Apple and Day APPDAY Codechef Solution in C++ 17
// your code goes here // www.progies.in
int t , x ,y ;
cin >>t ;
while(t--) {
cin >> x >>y ;
if ( x %y ==0 )
cout << x/y << endl ;
else
cout << (x/y)+1 << endl ;
}
return 0;
}
Apple and Day APPDAY Codechef Solution in Python 3
Updating soon
Apple and Day APPDAY Codechef Solution in Java
You can get NZEC error while compiling so Submit it directly
/* 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 x=sc.nextInt();
int y=sc.nextInt();
if(x%y==0)
{
System.out.println(x/y);
}
else
{
System.out.println((x/y)+1);
}
}
}
}
Apple and Day APPDAY codechef solution