typedeflonglong LL; LL MOD; LL fac[100000 + 5]; LL quick_mod(LL a, LL b) { LL ans = 1; a %= MOD; while (b) { if (b & 1) { ans = ans * a % MOD; b--; } b >>= 1; a = a * a % MOD; } return ans; } LL C_one_by_one(LL n, LL m)//组合数一个一个算 { if (m > n) return0; LL ans = 1; for (int i = 1; i <= m; i++) { LL a = (n + i - m) % MOD; LL b = i % MOD; ans = ans * (a * quick_mod(b, MOD - 2) % MOD) % MOD; } return ans; } LL C(LL n, LL m) { if (n < m) return0; return fac[n] * quick_mod(fac[m] * fac[n - m]%MOD, p - 2) % p; } voidInit() { fac[0] = 1; for (int i = 1; i < 100000 + 5; i++) fac[i] = (fac[i - 1] * i) % MOD; } LL Lucas(LL n, LL m)//choose m from n { if (m == 0) return1; returnC(n % MOD, m % MOD) * Lucas(n / MOD, m / MOD) % MOD; }