Physical Address
304 North Cardinal St.
Dorchester Center, MA 02124
Chef wants to gift C chocolates to Botswal on his birthday. However, he has only X chocolates with him.
The cost of 1 chocolate is Y rupees.
Find the minimum money in rupees Chef needs to spend so that he can gift C chocolates to Botswal.
For each test case, output in a single line answer, the minimum money in rupees Chef needs to spend.
Input: 2
7 5 5
10 1 1
Output: 10
9
Test Case 1: Chef has to gift a total of 7 chocolates out of which he has 5 chocolates. Thus, Chef needs to buy 2 more chocolates, which costs him 10 rupees.
Test Case 2: Chef has to gift a total of 10 chocolates out of which he has 1 chocolate. Thus, Chef needs to buy 9 more chocolates, which costs him 9 rupees.
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); //System.in is a standard input stream
int T= scn.nextInt();
for(int i=0; i<T; i++){
int C= scn.nextInt();
int X= scn.nextInt();
int Y= scn.nextInt();
System.out.println((C-X)*Y);
}
}
}
#include <iostream>
using namespace std;
int main() {
int t;
cin>>t;
while(t--){
int a,b,c;
cin>>a>>b>>c;
int rem = a-b;
int cost = rem*c;
cout<<cost<<endl;
}
return 0;
}
T = int(input())
for i in range(T):
C,X,Y = map(int,input().split())
print((C-X)*Y)
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
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 >>