http://exam.upc.edu.cn/problem.php?cid=1287&pid=7
隔板法,组合数学
看到逆元的时候就该想到了
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 100010;
const int mod = 1e9+7;
ll A[1000200],inv[1000200];
ll qpow(ll a,ll n){
ll ret =1;
while(n){
if(n&1)ret*=a;
ret%=mod;
n>>=1;
a=(a*a)%mod;
}
return ret;
}
ll get_inv(ll a){
return qpow(a,mod-2);
}
ll C(ll n, ll m){
if(n==m||m==0)return 1;
return ((long long)A[n]*qpow(A[m],mod-2)%mod)*qpow(A[n-m],mod-2)%mod;
}
int n,x,y;
int main(){
cin>>n>>x>>y;
A[0]=1;
for(int i=1;i<=n+10;i++)
A[i]=A[i-1]*i%mod;
for(int i=n-1;i>=1;i--){
inv[i]=inv[i+1]*(i+1)%mod;
}
//cout<<C(3,0)<<endl;
ll ans=0;
int step = n/max(x,y);
for(int i=0;i<=step;i++){
ans+=C(n-(x-1)*(i)-1,i-1)*C(n-(y-1)*(i)-1,i-1)%mod;
ans%=mod;
}
cout<<ans<<endl;
}
/*
*/