Chef and Chocolates solution codechef
Chef has XX 5
rupee coins and YY 10
rupee coins. Chef goes to a shop to buy chocolates for Chefina where each chocolate costs ZZ rupees. Find the maximum number of chocolates that Chef can buy for Chefina.
Input Format
- The first line contains a single integer TT — the number of test cases. Then the test cases follow.
- The first and only line of each test case contains three integers XX, YY and ZZ — the number of
5
rupee coins, the number of10
rupee coins and the cost of each chocolate.
Output Format
Chef and Chocolates solution codechef
For each test case, output the maximum number of chocolates that Chef can buy for Chefina.
Constraints
- 1≤T≤1001≤T≤100
- 1≤X,Y,Z≤10001≤X,Y,Z≤1000
Chef and Chocolates solution codechef
Sample Input 1
4
10 10 10
3 1 8
8 1 3
4 4 1000
Sample Output 1
15
3
16
0
Explanation
Chef and Chocolates solution codechef
Test case 11: Chef has 10⋅5+10⋅10=15010⋅5+10⋅10=150 rupees in total. Since each chocolate costs 1010 rupees, Chef can spend all 150150 rupees and buy 1515 chocolates for Chefina.
Test case 22: Chef has 3⋅5+1⋅10=253⋅5+1⋅10=25 rupees in total. Since each chocolate costs 88 rupees, Chef can buy a maximum of 33 chocolates for Chefina, leaving him with 11 rupee.
Test case 33: Chef has 8⋅5+1⋅10=508⋅5+1⋅10=50 rupees in total. Since each chocolate costs 33 rupees, Chef can buy a maximum of 1616 chocolates for Chefina, leaving him with 22 rupee.
Test case 44: Chef has 4⋅5+4⋅10=604⋅5+4⋅10=60 rupees in total. Since each chocolate costs 10001000 rupees, Chef can buy no chocolate for Chefina, leaving him with 6060 rupees.