Hopscotch

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;
 
 
 
}
/*
 
*/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值