Please Fill out the Feedback Form for Code Radius

Apple and Day : APPDAY | CodeChef Solution

1 min read

Problem

You have N Apples.You can eat K 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 T denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains two space-separated integers N, 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

Sample

Input
3
3 3
3 2
Output
1
2

Explanation

Test case 1: Since K = 3 and N = 3,it requires only 1 day to eat all apples.
Test case 2: We have K = 2 and N = 3 > K, it require a minimum of 2 days to eat all apples..

Solution

cpp
#include <iostream> using namespace std; int main(){ 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; }

Please First Try to Solve Problem by Yourself.

You may like these posts

  • Problem In a Chess match "a + b", each player has a clock which shows a minutes at the start and whenever a player makes a move, b seconds are added to this player's clock. Ti…
  • Problem The purpose of this problem is to verify whether the method you are using to read input data is sufficiently fast to handle problems branded with the enormous Input/Ou…
  • Problem Chef has just started Programming, he is in first year of Engineering. Chef is reading about Relational Operators.Relational Operators are operators which check relati…
  • Problem Gru has not been in the limelight for a long time and is, therefore, planning something particularly nefarious. Frustrated by his minions' incapability which has kept him…
  • Problem Write a program to obtain a number NN and increment its value by 1 if the number is divisible by 4 otherwise decrement its value by 1. Please Share this article... …
  •  ProblemYou're given an integer N. Write a program to calculate the sum of all the digits of N. Please Share this article... Input Format The first line contains an intege…

Post a Comment