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. Android学习之多点触摸并不神秘

    最近研究了一下多点触摸,写了个利用多点触摸来控制图片大小和单点触摸控制图片移动的程序,和大家分享分享. Android中监听触摸事件是onTouchEvent方法,它的参数为MotionEvent,下 ...

  2. 对return 语句的正确性和效率进行检查

    注意事项如下: 1. return 语句不可返回指向"堆栈内存“的”指针“或者”引用“,因为该内存单元在函数体结束时被自动释放. //错误 char* Func(void) { char s ...

  3. android高仿微信UI点击头像显示大图片效果

    用过微信的朋友朋友都见过微信中点击对方头像显示会加载大图,先贴两张图片说明下: 这种UI效果对用户的体验不错,今天突然有了灵感,试着去实现,结果就出来了.. 下面说说我的思路: 1.点击图片时跳转到另 ...

  4. Java基础知识强化62:Arrays工具类之概述和使用

    1. Arrays工具类: Arrays这个类包含操作数组(比如排序和查找)的各种方法. 2. Arrays的方法: (1)toString方法:把数组转成字符串 public static Stri ...

  5. mybati的存储过程

    这里我就以的存储过程为例,大家一起学习一下,

  6. 服务 远程服务 AIDL 进程间通讯 IPC 深化

    示例 aidl接口文件 package com.bqt.aidlservice.aidl; parcelable Person;  package com.bqt.aidlservice.aidl; ...

  7. django: db - many to many

    本讲介绍数据库多对多关系,代码样例继前文使用. 一,在 blog/models.py 中创建对象: # Many-To-Many Example : Authors vs Books class Au ...

  8. Path对象

    Path是连续的Segment的集合,除了 Path 的第一个Segment和最后一个Segment外,其余的Segment的起始点都是前一个Segment的终止点,即Path对象的中的Segment ...

  9. ISO3834认证所需的部分标准

    SO9606-1 焊工考试——熔化焊——第一部分:钢 ISO9606-2 焊工考试——熔化焊——第二部分:铝及铝合金 ISO14732 焊接人员——金属材料全机械化及自动化焊接的熔化焊操作攻击电阻焊安 ...

  10. nodejs个人配置

    国内镜像,飞一般的感觉!编辑 ~/.npmrc 加入下面内容 registry = http://registry.cnpmjs.org npm config set registry  http:/ ...