Wednesday, 26 January 2022

Input Format

  • The first line of input contains an integer T, denoting the number of test cases. The description of T test cases follows.
  • The first and only line of each test case contains three space-separated integers X,Y and Z — 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

  • 1T100
  • 1X,Y104
  • YZ104

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 X=2 stocks for Y=5 each, making the total amount spent by Chef =25=10.

Chef can sell this stock today for Z=20, making the total amount received by Chef =220=40.

The total profit is then the amount received minus the amount spent, which equals 4010=30.

Test Case 2: Chef bought X=3 stocks for Y=1 each, making the total amount spent by Chef =31=3.

Chef can sell this stock today for Z=2, making the total amount received by Chef =32=6.

The total profit is then the amount received minus the amount spent, which equals 63=3.

Test Case 3: Chef bought X=4 stocks for Y=5 each, making the total amount spent by Chef =45=20.

Chef can sell this stock today for Z=6, making the total amount received by Chef =46=24.

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