Three Families
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
(x+y)/3
#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的更多相关文章
- [ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]
Three Families Three families share a garden. They usually clean the garden together at the end o ...
- 【论文笔记】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 ...
- Feuding Families and Former Friends: Unsupervised Learning for Dynamic Fictional Relationships-Naacl 2016-20160422
1.Information publication:-Naacl 2016 2.What 根据小说中的人物描述,a)在每个时间段给出,人物关系的描述的概率分布,b)从时间轴上看出关系的变化轨迹,提出模 ...
- 指数族分布(Exponential Families of Distributions)
指数族分布是一大类分布,基本形式为: T(x)是x的充分统计量(能为相应分布提供足够信息的统计量) 为了满足归一化条件,有: 可以看出,当T(x)=x时,e^A(theta)是h(x)的拉普拉斯变换. ...
- 【原】AFNetworking源码阅读(二)
[原]AFNetworking源码阅读(二) 本文转载请注明出处 —— polobymulberry-博客园 1. 前言 上一篇中我们在iOS Example代码中提到了AFHTTPSessionMa ...
- Linux初识
在这篇文章中你讲看到如下内容: 计算机的组成及功能: Linux发行版之间的区别和联系: Linux发行版的基础目录及功用规定: Linux系统设计的哲学思想: Linux系统上获取命令帮助,及man ...
- go-hbase的Scan模型源码分析
git地址在这里: https://github.com/Lazyshot/go-hbase 这是一个使用go操作hbase的行为. 分析scan行为 如何使用scan看下面这个例子,伪代码如下: f ...
- PHP数组详解
作为一名C++程序员,在转做PHP开发的过程中,对PHP数组产生了一些混淆,与C++数组有相似的地方,也有一些不同,下面就全面地分析一下PHP的数组及其与C++中相应数据类型的区别和联系. 数组的分类 ...
- 【机器学习Machine Learning】资料大全
昨天总结了深度学习的资料,今天把机器学习的资料也总结一下(友情提示:有些网站需要"科学上网"^_^) 推荐几本好书: 1.Pattern Recognition and Machi ...
随机推荐
- Java基础知识强化35:String类之String的其他功能
1. String类的其他功能: (1)替换功能: String replace(char old, char new) String replace(String old,String new) ( ...
- ViutualBox虚拟机里添加磁盘
1.首先在VirtualBox界面给虚拟机添加一块磁盘 2. 启动系统,查看当前磁盘空间 Last login: Tue Mar 15 22:24:47 2016 from 192.168.1.100 ...
- nginx 配置访问正则匹配
server{ listen 80; server_name api.zyy.com; root /var/www/api_zyy; index index.php; location ~ /asse ...
- WPF资源字典使用
资源字典出现的初衷就在于可以实现多个项目之间的共享资源,资源字典只是一个简单的XAML文档,该文档除了存储希望使用的资源之外,不做任何其它的事情. 1. 创建资源字典 创建资源字典的过程比较简单,只 ...
- 启动外部exe程序
Process myProcess = new Process();myProcess.StartInfo.FileName = pathName;myProcess.Start();其中的pathN ...
- Hashtable键值集合
//Hashtable键值集合 键必须是维一的 类似于索引 Hashtable ht = new Hashtable(); ht.Add(, "中国"); ht.Add(, ); ...
- ZOJ3557 How Many Sets II( Lucas定理)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud How Many Sets II Time Limit: 2 Seconds ...
- Ajax实现三级联动(0520)
查询数据库中的chinastates表,通过父级代号查询相应省市区. 实现界面: 在js页面实现三级联动 在JQuery中调用Ajax方法(引用JQuery文件一定放在最上面) 用插件的形式,创建三个 ...
- php简单的爬虫
爬虫的原理是分析下载的页面,找出其中的连接,然后再下载这些链接,对链接再进行更深层次的递归,周而复始.在数据存储方面,先存储到redis里面,再有redis 写入到mysql,这样可以减轻mysql写 ...
- php 输出昨天,今天,明天是星期几的方法
<?php //php判断某一天是星期几的方法 function getWeek($unixTime=''){ $unixTime=is_numeric($unixTime)?$unixTime ...