Test Instructions: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.
Analysis :Mrs. C, the distribution of remuneration is by A and B .assign her that One-third job to complete the share. Understanding the meaning is easy to come to a conclusion.
input/Output requirements:
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).
Case output:
Sample Input
Sample Output
The procedure is as follows:
#include <iostream>#include<cstdio>using namespacestd;intMain () {intT; scanf ("%d",&T); while(t--) { intx, Y, Z scanf ("%d%d%d",&x,&y,&z); DoubleA,b,s,pay; S= (x+y)/3.0; A=x-s; b=y-s; pay=a/(a+b) *Z; Can be replaced by pay=a/(1/3 (x+y)) *z; intk=pay+0.5; printf ("%d\n", K); } return 0;}
//Note: The output is to be an integer.
CSU 1111. Three family. Third Audition D: Finishing the garden remuneration allocation problem