XDU 1032

#include<cstdio>
typedef long long ll;
const ll mod=; ll feima(ll a,ll b)
{
ll c=;
while(b)
{
if(b&)
c=c*a%mod;
a=a*a%mod;
b=b>>;
}
return c;
}
ll C(ll a,ll b)
{
if(a<b) return ;
if(a==b) return ;
if(b>a-b) b=a-b;
ll ca=,cb=;
for(ll i=;i<b;i++)
{
ca=ca*(a-i)%mod;
cb=cb*(b-i)%mod;
}
return ca*feima(cb,mod-)%mod;
}
/*LL Lucas(LL n,LL m)
{
if(m==0) return 1;
return C(n%p,m%p)*Lucas(n/p,m/p)%p;
}*/
ll Lucas(ll n,ll m)
{
ll ans=;
while(n&&m&&ans)
{
ans=ans%mod*C(n%mod,m%mod)%mod;
n/=mod;
m/=mod;
}
return ans;
} int main()
{
ll n,m;
while(~scanf("%lld%lld",&n,&m))
printf("%lld\n",Lucas(m,n));
return ;
}
上一篇:Linux 更改时区


下一篇:迅为4412开发板支持AVIN视频输入/AV监控摄像头输入模块