#include<algorithm> #include<cstdio> #include<queue> #include<cmath> #include<cstring> #include<iostream> #include<ctime> #include<cstdlib> #define ll long long using namespace std; const int mod=1e9+7; const int maxn=10000005; ll n,m,k; ll ans; ll q_pow(ll n,ll mi){ ll res=1,temp=n%mod; while(mi){ if(mi&1) res=res*temp%mod; temp=temp*temp%mod; mi>>=1; } return res; } ll cal(ll n,ll m){ // Cm(n,m)=(n!/(n-m)!) * (m!)^(mod-2)) mod mod if(m>n) return 0; // important ll res=1; for(int i=1;i<=m;i++){ ll t1=(n-m+i)%mod,t2=i%mod; res=res*(t1*q_pow(t2,mod-2)%mod)%mod; } return res; } /*Lucas(n,m,mod)=Cm(n%mod,m%mod)* Lucas(n/mod,m/mod,mod) Lucas(x,0,mod)=1;*/ ll lucas(ll t1,ll t2){ if(t2==0) return 1; return cal(t1%mod,t2%mod)*lucas(t1/mod,t2/mod)%mod; } int main(){ // int t; // scanf("%d",&t); // while(t--){ // scanf("%lld",&n); // cout<<lucas(n-1,n/2)<<endl; // } // scanf("%lld%lld",&n,&m); cin>>n>>m>>k; ll N0=lucas(n+m-1,n-1); ll num=(n+m+1)/(k+1); for(int i=1;i<=num;i++){ ans+=pow(-1,i+1)*lucas(n,i)*lucas((n+m-1)-(i*(k+1)),(n-1)); ans%=mod; } printf("%lld\n",N0-ans);//取模正确吗? // cout<<lucas(25,5)-(lucas(6,1)*lucas(16,5))+(lucas(6,2)*lucas(7,5)); // printf("Time used= %.2f\n",(double)clock()/CLOCKS_PER_SEC); // system("pause"); return 0; }
点赞 9

相关推荐

牛客网
牛客企业服务