Description
There are three families with a garden, and the wives of each family are required to help arrange the garden. Mrs. A worked for 5 days, and Mrs. B worked for 4 days before finishing the garden. Mrs. C was 90 yuan because she was pregnant unable to join them. How is this money assigned to a and B two wives more appropriate? How many dollars does A deserve? 90/(5+4) *5=$50 yuan? If you think so, you'll be fooled! The correct answer is 60 yuan. If you don't get it, think again.
Here's a general question: Suppose Mrs. A worked for x days, Mrs. B worked for y days, and Mrs. C paid $90, how much does Mrs. a deserve? The input guarantees that two wives should be given non-negative integer dollars. Three wives work the same.
Friendship Hint: There is a small trap in the subject. If the answer is wrong, please check the code carefully.
Input
Enter the number of first behavior Data group T (T<=20). Only one row per group of data, containing three integers x, y, Z (1<=x, y<=10,1<=z<=1000).
Output
For each set of data, output an integer, that is, the amount that Mrs. a deserves (unit: yuan).
Sample Input
2
5 4 90
8 4 123
Sample Output
60
123
Hint
If using floating-point numbers, be careful about the error, and use rounding as much as possible when outputting.
problem-solving ideas: First we do not fall into the trap of the problem. Give an example a concrete idea! For example a B two wives work for n hours, then this n hours should have been done by a B C three wife. Now consider the average number of hours each wife needs to work, and then calculate how many hours a B has worked for Mrs. C. Finally, we can get the reward that Mrs. A can receive.
Program code:
#include <stdio.h>
Main ()
{
int x, y, Z;
int T;
cin>>t;
while (t--)
{
scanf ("%d%d%d", &x,&y,&z);
printf ("%d\n", 3*z*x/(x+y)-Z);
}
return 0;
}
ACM CLEANS the Garden problem