CodeForces 768FBarrels and boxes
来源:互联网 发布:怀孕多久把脉能知男女 编辑:程序博客网 时间:2024/05/29 13:47
#include<bits/stdc++.h>using namespace std;const int N=2e5+5,P=1e9+7;int fac[N],ifac[N],inv[N],f,w,h;void pre() { fac[0]=ifac[0]=inv[1]=1; for(int i=1;i<N;++i)fac[i]=1ll*i*fac[i-1]%P; for(int i=2;i<N;++i)inv[i]=1ll*(P-P/i)*inv[P%i]%P; for(int i=1;i<N;++i)ifac[i]=1ll*inv[i]*ifac[i-1]%P;}int C(int n,int m){ if(m<0||n<m)return 0; return 1ll*fac[n]*ifac[n-m]%P*ifac[m]%P;}int calc(int r,int b,int k){ if(!b)return 1; int ans=0; for(int i=1;i<=r+1&&(!k||i*k<=b);++i){ ans+=1ll*C(r+1,i)*C(b-k*i-1,i-1)%P; ans%=P; }return ans;}int pow(int x,int n){ int y=1; while(n){ if(n&1)y=1ll*y*x%P; x=1ll*x*x%P; n>>=1; }return y;}int Inv(int x){return pow(x,P-2);}int main(){ pre(); scanf("%d %d %d",&f,&w,&h); int s=calc(f,w,h),d=C(f+w,w); cout<<1ll*s*Inv(d)%P;}
1 0
- CodeForces 768FBarrels and boxes
- Okabe and Boxes CodeForces
- Balls and Boxes CodeForces
- Boxes And Balls CodeForces
- Codeforces#420 Okabe and Boxes
- 栈 Okabe and Boxes:CodeForces
- CodeForces 390C Inna and Candy Boxes
- Codeforces #229 D2C:Inna and Candy Boxes
- codeforces 390c Inna and Candy Boxes
- codeforces 390C Inna and Candy Boxes
- Codeforces 821 C. Okabe and Boxes
- Codeforces 821C-Okabe and Boxes
- Codeforces 821C Okabe and Boxes 题解
- codeforces 420 div2 C Okabe and Boxes
- Codeforces#420 C. Okabe and Boxes
- 【Codeforces 821C. Okabe and Boxes】
- Codeforces Round #420 C. Okabe and Boxes
- codeforces 420-C. Okabe and Boxes
- ZUFE2481 神奇的字符串
- echarts图表横轴个性化设置
- 【年度盛宴】2012年度最佳 Web 前端开发工具和框架——《上篇》
- pickerview实现底部弹出选择时间
- JavaScript的this对象,什么意思
- CodeForces 768FBarrels and boxes
- 分布式架构学习之:022--Dubbo负载均衡
- vue组件里面引入highchars
- 解决java.lang.SecurityException: Package android does not belong to 10065
- new 和 delete 运算符
- mysql 基本的增删查改操作
- 计算页面所有的ul里面有几个li
- easyui dialog 伸缩阴影问题
- 控件学习