(Lucas)定理:
(C^x_y≡C^{x/p}_{y/p}*C^{x\%p}_{y\%p} ~~(mod~p))
证明不会2333
void pre(){
A[0]=A[1]=B[0]=B[1]=1;
for(int i=2;i<MOD;i++){B[i]=-B[MOD%i]*(MOD/i)%MOD;}
for(int i=2;i<MOD;i++)
A[i]=A[i-1]*i%MOD,
B[i]=B[i-1]*B[i]%MOD;
}
LL C(int n,int m){
if(m>n)return 0;m=min(m,n-m);
return 1ll*A[n]*B[n-m]%MOD*B[m]%MOD;
}
LL Lucas(int n,int m){
if(m==0)return 1;
return Lucas(n/p,m/p)*C(n%p,m%p);
}