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 (   T[ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]100), the number of test cases. Each test case contains three integers x,    y,    z (   1[ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]x,    y[ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]10,    1[ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]z[ACM_水题] UVA 12502 Three Families [2人干3人的活后分钱,水]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

题目大意:水题,不解释。推出计算公式瞬秒!
 1 #include<iostream>
 2 #include<cstdio>
 3 using namespace std;
 4 int main(){
 5     int T;cin>>T;
 6     while(T--){
 7         int x,y,z;
 8         cin>>x>>y>>z;
 9         cout<<(3*x*z)/(x+y)-z<<'\n';
10     }return 0;
11 }

 



相关文章:

  • 2022-01-07
  • 2022-02-04
  • 2021-06-21
  • 2022-01-01
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-01-30
  • 2021-10-13
  • 2021-09-02
  • 2021-08-04
  • 2021-07-13
  • 2022-03-04
  • 2021-11-01
相关资源
相似解决方案