线性求组合数
要求模数比 (n) 大。
const int MOD = 998244353;
const int MAXN = 3e5 + 5;
ll inv[MAXN], fac[MAXN], invfac[MAXN];
void init_C(int n) {
inv[1] = 1;
for(int i = 2; i <= n; i++)
inv[i] = inv[MOD % i] * (MOD - MOD / i) % MOD;
fac[0] = 1, invfac[0] = 1;
for(int i = 1; i <= n; i++) {
fac[i] = fac[i - 1] * i % MOD;
invfac[i] = invfac[i - 1] * inv[i] % MOD;
}
}
ll C(ll n, ll m) {
if(n < 0 || m < 0 || n - m < 0)
return 0;
return fac[n] * invfac[n - m] % MOD * invfac[m] % MOD;
}