f数组是求阶乘的,可以开大点。

#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
using namespace std;
#define  inf  0x3f3f3f3f
#define ll long long
#define mod 1000000007
#define maxn 1000005
ll f[maxn];
void init(){
    f[0] = 1;
    for (int i=1; i<=maxn; ++i) f[i] = f[i-1] * i % mod;
}
ll fastpow(ll x,ll y){
    ll ans=1;
    ll res=x;
    while(y){
        if(y&1)ans=(ans*res)%mod;
        res=(res*res)%mod;
        y>>=1;
    }
    return ans;
}
ll lucas(ll n,ll k){
    ll ans=1;
    while(n&&k){
        ll nn=n%mod;
        ll kk=k%mod;
        if(nn<kk)return 0;
        ans=ans*f[nn]*fastpow(f[kk]*f[nn-kk]%mod,mod-2)%mod;
        n/=mod;k/=mod;
    }
    return ans;
}
int main(){
ll n,k;
init();
scanf("%lld%lld",&n,&k);
printf("%lld\n",lucas(n,k));
return 0;
}