Competition--Arranging the garden problem--solving report

Source: Internet
Author: User

Arranging garden problems

Main topic:

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. Requirements:InputEnter 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: Sample Input
Sample Output


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

Topic Analysis:
This is a typical mathematical problem. The first thing to do is to make a formula, to find the formula and write the program is simple. To get the money from Mrs. A, because the floating-point number is the problem, the formula is calculated according to the calculation
Three people do each should do the number of days s= (X+Y)/3.0; A more days to do a=x-s; b More days to do b=y-s; c should be paid a pay=a/(a+b) *z.
Program code:
1#include <cstdio>2#include <iostream>3 using namespacestd;4 5 intt[ -];6 inty[Ten];7 intz[ +];8 9 intMain ()Ten { One     intT; Ascanf"%d",&T); -      while(t--) -     { the     intx, y, z -     DoubleA,b,s,pay; -      -      +scanf"%d%d%d",&x,&y,&z); -      +s= (x+y)/3.0;//Three people do the number of days each should do AA=x-s;//a more days to do atB=y-s;//b More days to do -pay=a/(a+b) *z;//c The amount of money payable to a -         intk=pay+0.5;//rounding up the money to get an integer -cout<<k<<Endl; -     } -     return 0; in      -}

Experience:
This problem seems simple, but it is in the calculation of a should get how much money, always can not find the relationship, so calculated for a long time. After the relationship is found, the program will be finished soon. It's a very simple question.

Feel that they have some problems in thinking, the next time you should do more math problems, exercise their own thinking ability.



Competition--Arranging the garden problem--solving report

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.