UVA 12502 Three Families (A)

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$ \le$100), the number of test cases. Each test case contains three integers xyz (1$ \le$xy$ \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

思路:主要要考虑到A,B除了帮第三个家庭分担外,本身自己也是要做工作的。所以5,4共做9小时,那么每个家庭要做3个小时。
则A帮C分担了2个小时,B帮C分担了1个小时,所以A获得90*2/3.
得出公式后时除法可能出错,要放到最后。

 1 #include <iostream>
 2 #include <cstring>
 3 #include <cstdio>
 4 #include <string>
 5 using namespace std;
 6 int x, y, z;
 7 int T;
 8 int main(){
 9     scanf("%d", &T);
10     while(T--){
11         scanf("%d%d%d", &x, &y, &z);
12         if(x > (x+y)/3){
13             printf("%d\n",(2*x-y)*z/(x+y));
14         }
15         else printf("0\n");
16     }
17     
18     return 0;
19 }

 



 

转载于:https://www.cnblogs.com/titicia/p/3917221.html

sm.families.Binomial()是Statsmodels包中的一种用于构建二项式分布模型的类。在Logistic回归中,我们通常使用二项式分布来建立模型,因为它可以描述二元变量的分布情况。 sm.families.Binomial()类用于指定二项式分布模型的参数和分布类型,包括: 1. link:用于描述因变量和自变量之间的关系,通常使用Logit函数。 2. variance:用于描述因变量的方差,通常为Binomial()。 3. power:用于描述一些特殊的分布类型,通常为1.0,表示二项式分布。 在使用sm.families.Binomial()类时,我们可以指定参数和分布类型,然后将其作为参数传递给Logit函数,从而构建Logistic回归模型。 例如,下面的代码演示了如何使用sm.families.Binomial()类构建二项式分布模型: ``` import statsmodels.api as sm import pandas as pd # 读取数据 data = pd.read_csv('data.csv') # 将目标变量转换为二元变量 data['target'] = data['target'].apply(lambda x: 1 if x == 'yes' else 0) # 构建二项式分布模型 binom = sm.families.Binomial() # 使用Logit函数拟合模型 model = sm.Logit(data['target'], data[['var1', 'var2', 'var3']], family=binom) result = model.fit() # 输出模型摘要信息 print(result.summary()) ``` 在上面的代码中,我们首先读取数据并将目标变量转换为二元变量,然后使用sm.families.Binomial()类构建二项式分布模型,并将其作为参数传递给Logit函数,最后使用fit()方法拟合模型并输出摘要信息。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值