组合数
\(O(n^2)\):
ll c[1005][1005];
const int mod=1e9+7;
for (int i=0; i<=1000; ++i)
{
c[i][0]=c[i][i]=1;
for (int j=1; j<i; ++j)
c[i][j]=(c[i-1][j]+c[i-1][j-1])%mod;
}
\(O(n+log(mod))\):
const int maxn=2e5+5;
const int mod=998244353;
ll fac[maxn];//阶乘
ll qpow(ll x, ll n)
{
ll ans=1;
while(n>0){
if(n&1) ans=(ans*x)%mod;
x=(x*x)%mod,n>>=1;
}
return ans;
}
void init()
{
fac[0]=1;
for(int i=1;i<maxn;i++)
fac[i]=(fac[i-1])*i%mod;
}
ll C(ll n, ll k)//从n个数里选k个数
{
return fac[n]*qpow(fac[k]*fac[n-k]%mod, mod-2)%mod;
}
CAD加油!欢迎跟我一起讨论学习算法,QQ:1401650042