Practice

* Author:* Ritvik

*Ritvik*

**Tester:***Ritvik*

**Editorialist:**# DIFFICULTY:

EASY

# PREREQUISITES:

Math

# PROBLEM:

Find the individual quantity of all three packs from * n* packs and the total cost of all packs, given the total and combined quantities (x, y, z) and cost of all packs (20, 30, 40).

# EXPLANATION:

Given combined quantities of every two packs (x, y, z) and total quantity * n*. Let say the individual quantity is a, b, c of all three packs respectively. x=(a+b), y=(b+c) and z=(c+a) is given, therefore individual quantities is figured out by a=n-y, b=n-z, and c=n-x. Cost for a is 20, b is 30, and c is 40 (mentioned in the prompt). So multiplying the quantities a, b, c with its respective cost solves the problem.

Hence for each a, b, c, individual quantity and total cost can be determined using the above approach.

# SOLUTION:

## Setter's Solution

```
#include <iostream>
using namespace std;
int main() {
int t;
cin >> t; // input number of test cases
while (t--) { // looping the code in the scope till the last test case
int x, y, z, n;
cin >> x >> y >> z >> n;
cout << n - y << " " << n - z << " " << n - x << " ";
cout << (n - y) * 20 + (n - z) * 30 + (n - x) * 40 << endl;
}
return 0;
}
```