http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=3946


Three Families

Three families share a garden. They usually clean the garden together at the end of each week, but last week, family C was on holiday, so family A spent 5 hours, family B spent 4 hours and had everything done. After coming back, family C is willing to pay $90 to the other two families. How much should family A get? You may assume both families were cleaning at the same speed.

$90/(5+4)*5=$50? No no no. Think hard. The correct answer is $60. When you figured out why, answer the following question: If family A and B spent x and y hours respectively, and family C paid $z, how much should family A get? It is guaranteed that both families should get non-negative integer dollars.

WARNING: Try to avoid floating-point numbers. If you really need to, be careful!

Input

The first line contains an integer 
T
 (
T100
), the number of test cases. Each test case contains three integers 
x

y

z
 (
1x

y10
,

1z1000
).

Output

For each test case, print an integer, representing the amount of dollars that family A should get.

Sample Input

2
5 4 90
8 4 123

Sample Output

60
123

Problemsetter: Rujia Liu, Special Thanks: Feng Chen, Md. Mahbubul Hasann, Youzhi Bao



这个题就以纯粹数学题,能想通公式则不要10行代码解决,想不到公式想死都做不出来。。。

这题是2012年湖南省省赛签到题。。。。。

思路:他们三家共用一个花园,还是平局分的,三家工作效率相同,那么也就是说三家修剪草坪的总时间相同,现在只有2家人做3家人的活。
则每家修剪草坪的时间为: 
(x+y)/3
由此可知A,B两家给C修剪的时间分别为:x-(x+y)/3   和  y-(x+y)/3
C给A、B支付报酬是按比例支付的,则A的报酬为:z*(x-(x+y)/3)/(x-(x+y)/3+y-(x+y)/3)

AC代码:
#include<iostream>
#include<cstdio> int main()
{
int t,x,y,z,mu;
scanf("%d",&t);
while(t--)
{
scanf("%d%d%d",&x,&y,&z);
mu = z*(x-(x+y)/3)/(x-(x+y)/3+y-(x+y)/3);
printf("%d\n",mu);
} return 0;
}

Three Families的更多相关文章

  1. [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]

      Three Families  Three families share a garden. They usually clean the garden together at the end o ...

  2. 【论文笔记】DeepOrigin: End-to-End Deep Learning for Detection of New Malware Families

    DeepOrigin: End-to-End Deep Learning for Detection of New Malware Families 标签(空格分隔): 论文 论文基本信息 会议: I ...

  3. Feuding Families and Former Friends: Unsupervised Learning for Dynamic Fictional Relationships-Naacl 2016-20160422

    1.Information publication:-Naacl 2016 2.What 根据小说中的人物描述,a)在每个时间段给出,人物关系的描述的概率分布,b)从时间轴上看出关系的变化轨迹,提出模 ...

  4. 指数族分布(Exponential Families of Distributions)

    指数族分布是一大类分布,基本形式为: T(x)是x的充分统计量(能为相应分布提供足够信息的统计量) 为了满足归一化条件,有: 可以看出,当T(x)=x时,e^A(theta)是h(x)的拉普拉斯变换. ...

  5. 【原】AFNetworking源码阅读(二)

    [原]AFNetworking源码阅读(二) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇中我们在iOS Example代码中提到了AFHTTPSessionMa ...

  6. Linux初识

    在这篇文章中你讲看到如下内容: 计算机的组成及功能: Linux发行版之间的区别和联系: Linux发行版的基础目录及功用规定: Linux系统设计的哲学思想: Linux系统上获取命令帮助,及man ...

  7. go-hbase的Scan模型源码分析

    git地址在这里: https://github.com/Lazyshot/go-hbase 这是一个使用go操作hbase的行为. 分析scan行为 如何使用scan看下面这个例子,伪代码如下: f ...

  8. PHP数组详解

    作为一名C++程序员,在转做PHP开发的过程中,对PHP数组产生了一些混淆,与C++数组有相似的地方,也有一些不同,下面就全面地分析一下PHP的数组及其与C++中相应数据类型的区别和联系. 数组的分类 ...

  9. 【机器学习Machine Learning】资料大全

    昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...

随机推荐

  1. CRT远程连接server字符输出乱码解决一例

    CRT远程连接server字符输出乱码解决一例 环境: server:Centos 6.2 远端:win 7 CRT版本号:7.1.1 现象回想: 1.server端:中文字符显示正常,例如以下: 2 ...

  2. Android RatingBar自定义替换系统图片

    1.自定义替换提醒☆图片,准备两个图片添加到系统中去:如下:        在drewable下定义一个图片资源ratingbar_drawable.xml 1 2 3 4 5 6 7 8 9 10 ...

  3. Ignatius and the Princess III --undo

    Ignatius and the Princess III Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (J ...

  4. 为什么HikariCP被号称为性能最好的Java数据库连接池,怎样配置使用

    HiKariCP是数据库连接池的一个后起之秀.号称性能最好.能够完美地PK掉其它连接池. 原文地址:http://blog.csdn.net/clementad/article/details/469 ...

  5. Unity 制作虚拟手柄例子

    Unity不愧是收费开发软件,有写好的Joystick(虚拟手柄),使用起来很简单,我们一起来学习一下哈!! 本文源代码Win版的 :http://vdisk.weibo.com/s/BDn59yfn ...

  6. 关于winform主题IrisSkin2的编写

    第一步:首先引用IrisSkin2.dll. 第二步自定义类: /// <summary> /// 窗体主题边界类 /// </summary> public class Fo ...

  7. eclipse安装ADT插件重启后不显示Android SDK Manager和Android Virtual Device Manager图标的一种解决办法

    通常安装,搭建安卓环境后,不显示Android SDK Manager和Android Virtual Device Manager ize解决方法:Eclipse ->window->c ...

  8. Tiling_easy version(填2 x N的格子的种类)

    E - Tiling_easy version 题目大意: 有一个大小是 2 x n 的网格,现在需要用2种规格的骨牌铺满,骨牌规格分别是 2 x 1 和 2 x 2,请计算一共有多少种铺设的方法. ...

  9. jQuery select 操作全集

    添加option $('#id').append("<option value="value">Text</option>");//为s ...

  10. zendguard安装破解

    http://www.thefox.cn/zend-guard.shtml 到官网下载6.0版本安装后 URL: http://www.zend.com/en/products/guard/downl ...