1111: Three tips for people to solve problems

Source: Internet
Author: User

Original question:

1111: Three family time limit:1 Sec Memory limit:128 MB
Description has three families with a garden, and the wives of each family are required to help organize 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
25 4 908) 4 123
Sample Output
60123
HINT

If using floating-point numbers, be careful about the error, and use rounding as much as possible when outputting.

Analysis: First of all, the first test of a mathematical study questions, in fact, the truth is very simple, analysis under the title of a deserved 60 yuan of the truth bar.

Originally was to three people to do together, now 2 people do, 2 people altogether spent 9 days, everyone work efficiency is the same, so the work is 9 days, so split up each person to do 3 days, but now C did not do, C of workload please a a share, share of how much money, a share 2 days, b Shared 1 days, so a was two-thirds, that is, 60 yuan;

Know the test instructions after it is very simple, a few lines of code can be done, need to pay a little attention to the amount of money will be multiplied by the proportion of the decimal, so to use a double type storage, the final rounding, with floor (apay+0.5) can be.

My code is as follows

#include <iostream>#include<cstdio>#include<cmath>using namespacestd;intMain () {intx, y, T, Z; CIN>>T;  while(t--) {cin>> x>>y>>Z; DoubleAve = (Double) (x + y)/3; DoubleAexp = X-ave;DoubleBexp = y-Ave; if(Aexp <0) Aexp =0; if(Bexp <0) Bexp =0; DoubleApay = (z* (aexp/(Aexp +( bexp))); cout<< Floor (apay+0.5) <<Endl; }    return 0;}
View Code

1111: Three tips for people to solve problems

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.