[Solution] Chef and the Hair Salon solution codechef

Chef recently realized that he needs a haircut, and went to his favorite hair salon. At the salon, he found NN customers waiting for their haircuts. From his past experience, Chef knows that the salon takes MM minutes per customer. Only one person can get their haircut at a time.

For how many minutes will Chef have to wait before he can get his haircut?

Input Format

  • The first line of 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 NN and MM, as described in the problem.

Output Format

For each test case, print a single line containing one integer — the number of minutes that Chef will have to wait before he can get his haircut.


  • 1T10001≤T≤1000
  • 0N10000≤N≤1000
  • 1M10001≤M≤1000


Subtask #1 (100 points): Original constraints

Sample Input 1 

2 15
0 15

Sample Output 1 



Test case 11: There are 22 customers waiting for the haircut and the salon will take 1515 minutes for each customer, hence Chef will have to wait for 3030 minutes before he can get his haircut.

Test case 22: There are 00 customers waiting for the haircut, therefore the Chef will not have wait to get the haircut.

Leave a Comment