• 博客园logo
  • 会员
  • 周边
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • YouClaw
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
HaibaraAi
博客园    首页    新随笔    联系   管理    订阅  订阅

Uva 12502 - Three Families

你为何这么叼!

Three Families 

Time limit: 1.000 seconds 

 

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 (T$ \le$100), the number of test cases. Each test case contains three integers x, y, z (1$ \le$x, y$ \le$10, 1$ \le$z$ \le$1000).

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

 

 1 #include <cstdio>
 2 #include <cstring>
 3 #include <algorithm>
 4 using namespace std;
 5 int n,m,k;
 6 int main(){
 7     int t;
 8     scanf("%d",&t);
 9     while(t--){
10         scanf("%d%d%d",&n,&m,&k);
11         printf("%d\n",k*(2*n-m)/((n+m)));
12     }
13     return 0;
14 }
View Code 2013-10-11 18:44:36

 

posted @ 2013-10-11 18:44  HaibaraAi  阅读(117)  评论(0)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2026
浙公网安备 33010602011771号 浙ICP备2021040463号-3