Input Format
- The first line of input contains an integer , denoting the number of test cases. The description of test cases follows.
- The first and only line of each test case contains three space-separated integers and — the number of stocks, the price they were bought at, and the price they can be sold at, respectively.
Output Format
For each test case print on a new line a single integer — Chef's profit after selling all the stocks he has.
Constraints
Sample Input 1
3
2 5 20
3 1 2
4 5 6
Sample Output 1
30
3
4
Explanation
Test Case 1: Chef bought stocks for each, making the total amount spent by Chef .
Chef can sell this stock today for , making the total amount received by Chef .
The total profit is then the amount received minus the amount spent, which equals .
Test Case 2: Chef bought stocks for each, making the total amount spent by Chef .
Chef can sell this stock today for , making the total amount received by Chef .
The total profit is then the amount received minus the amount spent, which equals .
Test Case 3: Chef bought stocks for each, making the total amount spent by Chef .
Chef can sell this stock today for , making the total amount received by Chef .
The total profit is then the amount received minus the amount spent, which equals
Solution
#include <iostream>
using namespace std;
int main()
{
int t;
cin>>t;
while(t--){
int x,y,z;
cin>>x>>y>>z;
int a=x*y;
int b=x*z;
cout<<b-a<<endl;
}
return 0;
}
No comments:
Post a Comment