304 North Cardinal St.
Dorchester Center, MA 02124

# Chef and Chocolates CodeChef Solution

## Problem – Chef and Chocolates CodeChef Solution

Chef has X `5` rupee coins and Y `10` rupee coins. Chef goes to a shop to buy chocolates for Chefina where each chocolate costs Z rupees. Find the maximum number of chocolates that Chef can buy for Chefina.

### Input Format

• The first line contains a single integer T — the number of test cases. Then the test cases follow.
• The first and only line of each test case contains three integers XY and Z — the number of `5` rupee coins, the number of `10` rupee coins and the cost of each chocolate.

### Output Format

For each test case, output the maximum number of chocolates that Chef can buy for Chefina.

• 1≤T≤100
• 1≤X,Y,Z≤1000

### Sample 1:

``````Input: 4
10 10 10
3 1 8
8 1 3
4 4 1000
Output: 15
3
16
0``````

### Explanation:

Test case 1: Chef has 10⋅5+10⋅10=150 rupees in total. Since each chocolate costs 10 rupees, Chef can spend all 150 rupees and buy 15 chocolates for Chefina.

Test case 2: Chef has 3⋅5+1⋅10=25 rupees in total. Since each chocolate costs 8 rupees, Chef can buy a maximum of 3 chocolates for Chefina, leaving him with 1 rupee.

Test case 3: Chef has 8⋅5+1⋅10=50 rupees in total. Since each chocolate costs 3 rupees, Chef can buy a maximum of 16 chocolates for Chefina, leaving him with 2 rupee.

Test case 4: Chef has 4⋅5+4⋅10=60 rupees in total. Since each chocolate costs 1000 rupees, Chef can buy no chocolate for Chefina, leaving him with 60 rupees.

### Chef and Chocolates CodeChef Solution in C++17

``````#include<iostream>
using namespace std;
int main()
{
int t;
cin>>t;
if(t>=1&&t<=100)
{
while(t--)
{
int x,y,z;
cin>>x>>y>>z;
int hand=x*5+y*10;
int count=0;
for(int i=hand;i>=z;i-=z)
{
count++;
}
cout<<count<<endl;
}
}
return 0;
}``````

### Chef and Chocolates CodeChef Solution in Pyth 3

``````# cook your dish here
t=int(input())
for i in range(t):
x,y,z=[int(i) for i in input().split()]
money=x*5+y*10
print(money//z)``````

### Chef and Chocolates CodeChef Solution in Java

``````import java.util.*;
import java.lang.*;
import java.io.*;

class Codechef
{
public static void main (String[] args) throws java.lang.Exception
{
Scanner scn= new Scanner(System.in);
int T= scn.nextInt();
for(int i=0; i<T;i++){

int X= scn.nextInt();
int Y= scn.nextInt();
int Z= scn.nextInt();

System.out.println((X*5+Y*10)/Z);
}
}}
``````
##### Chef and Chocolates CodeChef Solution Review:

In our experience, we suggest you solve this Chef and Chocolates 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 Chef and Chocolates CodeChef Solution

Find on CodeChef

##### Conclusion:

I hope this Chef and Chocolates 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