[Solution] Chef and Chocolates solution codechef

Chef and Chocolates solution codechef – Chef wants to gift CC chocolates to Botswal on his birthday. However, he has only XX chocolates with him.
The cost of 11 chocolate is YY rupees.

Find the minimum money in rupees Chef needs to spend so that he can gift CC chocolates to Botswal.

Chef and Chocolates solution codechef

  • First line will contain TT, number of test cases. Then the test cases follow.
  • Each test case contains of a single line of input, three integers C,X,C,X, and YY.

Output Format

For each test case, output in a single line answer, the minimum money in rupees Chef needs to spend.

Constraints

  • 1T1001≤T≤100
  • 1C1001≤C≤100
  • 0XC0≤X≤C
  • 1Y1001≤Y≤100

Chef and Chocolates solution codechef

 

2
7 5 5
10 1 1

Sample Output 1 

10
9

Chef and Chocolates solution codechef

Test Case 11: Chef has to gift a total of 77 chocolates out of which he has 55 chocolates. Thus, Chef needs to buy 22 more chocolates, which costs him 1010 rupees.

Test Case 22: Chef has to gift a total of 1010 chocolates out of which he has 11 chocolate. Thus, Chef needs to buy 99 more chocolates, which costs him 99 rupees.

Leave a Comment