Back to Campus CodeChef Solution

Problem – Back to Campus CodeChef Solution

Finally, College has started calling students back to campus. There are so many students and thus due to some safety measures the college can’t call back all the students on the same day. It currently has the capacity of screening K students on a single day. There is a total of N students. What’s the minimum number of days required for all the students to be back on the campus?

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 for all the students to be back on the campus.

Constraints

  • 1≤T≤10^4
  • 1≤N≤10^2
  • 1≤K≤10^2

Sample 1:

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

Explanation:

Test case 1: Since K=3 and N=3, we can call all 3 students back to campus on the first day itself. Hence it requires only 1 day for all students to be back on campus.

Test case 2: We have K=2 and N=3>K, so we can’t call all the students back to campus on a single day. But we can call 1 student on the first day and the remaining 2 students on the second day. Therefore, we require a minimum of 2 days for all students to be back on campus.

Test case 3: We have K=3 and N=4>K, so we can’t call all the students back to campus on a single day. But we can call 2 students on the first day and the remaining 2 students on the second day. Therefore, we require a minimum of 2 days for all students to be back on campus.

Back to Campus CodeChef Solution in Pyth 3

# cook your dish here
import math
t = int(input())
for _ in range(t):
    n,k = map(int,input().split())
    print(math.ceil(n/k))

Back to Campus CodeChef Solution in C++14

#include <iostream>
using namespace std;


	// your code goes here
	int main() {
	int t;
	cin>>t;
	
	while(t--){
	    int n,k;
	    cin>>n>>k;
	    
	    if(n%k==0){
	        cout<<n/k<<endl;
	    }
	    else{
	        cout<<(n/k)+1<<endl;
	    }
	}
	return 0;
}


Back to Campus 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
	{
		// your code goes here
		Scanner in=new Scanner(System.in);
		int te=in.nextInt();
		while(te-->0)
		{
		int n=in.nextInt();
		int k=in.nextInt();
		int res=(int)n/k;
		if(n%k != 0)
		res+=1;
	    System.out.println(res);
	    
		} 
	}
}
Back to Campus CodeChef Solution Review:

In our experience, we suggest you solve this Back to Campus 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 Back to Campus CodeChef Solution

Find on CodeChef

Conclusion:

I hope this Back to Campus 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

Leave a Reply

Your email address will not be published. Required fields are marked *