UVa 12502-three Families

Source: Internet
Author: User

Title: There are three families ABC clean up a garden, each home cleans up the same speed, C family goes on vacation, only AB two home cleaning;

A home cleanup x hours, b home cleanup y hours, C family came back to pay the Z-dollar, ask a family how much money to get.

Analysis: Simple questions. Take a look at the sample, divide the garden into 3 parts, a total of 9 hours to clean up, each family's first 3 hours is their own;

So, a family cleaned up the C family part for 2 hours, and the B family cleaned up the C family part for 1 hours, so a family got $60.

The total is set at 3a hours, and C family Part B works for b hours, then the following equation:

Then set (2a-b)/(a+b) = k = x/Y (A-B)/a = (2k-1)/(k+1) = (2m-n)/(N+M).

Description: Rushed to the top 600 (⊙o⊙).

#include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include < Cstdio> #include <cmath>using namespace Std;int main () {int n,x,y,z;while (~scanf ("%d", &n)) for (int i = 0; i < n; + + i) {scanf ("%d%d%d", &x,&y,&z);p rintf ("%d\n", z* (2*x-y)/(X+y));}    return 0;}


UVa 12502-three Families

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.