typedef long long ll;
const int MAXN=1e5+5;
const ll MOD=1000000007;
long long  fac[MAXN], inv[MAXN];
inline long long C(long long a, long long b) {
    return fac[a] * inv[b] % MOD * inv[a - b] % MOD;
};

inline void init(){
    inv[0] = inv[1] = fac[0] = 1;
    for (int i = 2; i < MAXN; i++) {
        inv[i] = inv[MOD%i] * (MOD - MOD / i) % MOD;//递推求逆元
    }
    for (int i = 1; i < MAXN; i++) {
        fac[i] = fac[i - 1] * i%MOD;
        inv[i] = inv[i - 1] * inv[i] % MOD;//阶乘逆元
    }
}

标签: combinatorics

添加新评论