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. 五、SolrJ、Request Handler

    什么是SolrJ 既然Solr是以单独的WebApp形式存在的,那么Solr理应提供与Solr通信的Api吧,对的,这就是SolrJ,既然与solr通信是通过url,那么其实我们也可以不用SolrJ, ...

  2. Linux以KB显示内存大小

    Linux以KB显示内存大小 youhaidong@youhaidong-ThinkPad-Edge-E545:~$ free -k total used free shared buffers ca ...

  3. Hibernate项目里配置环境时,jar包配置不当会对测试结果产生影响。

    问题情况: 如下图所示,该图中,显示了一堆错误的jar包.这是导致了Junit4测试通过了,数据库却没反应的原因. 原因: 之所以出现这种情况,eclipse其实已经告诉了我们原因.如下图所示,这些j ...

  4. DataGrid( 数据表格) 组件[9]

    本节课重点了解 EasyUI 中 DataGrid(数据表格)组件的使用方法,这个组件依赖于Panel(面板).Resizeable(调整大小).LinkButton(按钮).Pageination( ...

  5. Css的三大机制(特性):特殊性、继承、层叠详解

    继承(Inheritance)是从一个元素向其后代元素传递属性值所采用的机制.确定应当向一个元素应用那些值时,用户代理(浏览器)不仅要考虑继承,还要考虑声明的特殊性(specificity),另外需要 ...

  6. SqlServer跨域查询

    SELECT * FROM OPENDATASOURCE('SQLOLEDB','Data Source=192.168.1.14;User ID=sa;Password=sql.com').eBui ...

  7. 网络NSURLSession

    简单下载图片 dispatch_queue_t queue =dispatch_queue_create(NULL, DISPATCH_QUEUE_CONCURRENT); dispatch_asyn ...

  8. java下tcp的socket连接案例

    package cn.stat.p4.ipdemo; import java.io.BufferedReader; import java.io.IOException; import java.io ...

  9. 关于javascript中setTimeout()和clearTimeout()的疑惑。

    由于在w3school中学习javascript时,当学到setTimeout()和clearTimeout()方法时.根据它所提供的例子(下面的代码转自w3cschool)—计数程序,发现当你不停的 ...

  10. 树形dp hdu1561

    有的堡垒攻克需要攻克另一个堡垒,形成一个森林,最多攻克m个堡垒,求获得宝物的最大价值. 1,以0做根将森林形成树: 2,用背包计算当前节点下需要攻克k个堡垒能获得的宝物最大价值,但是注意同一个根节点的 ...