组合数

https://www.zybuluo.com/ArrowLLL/note/713749

Pascal 公式打表组合数取模

const int maxn = 1e3 + 5;
const int mod = 1e5 + 3;
int tC[maxn][maxn];

inline int C(int n, int k)
{
    if (k > n) return 0;
    return tC[n][k];
}

void calcC(int n)
{
    for (int i = 0; i < n; i++) {
        tC[i][0] = 1;
        for (int j = 1; j < i; j++) {
            tC[i][j] = (C(i - 1, j - 1) + C(i - 1, j)) % mod;
        }
        tC[i][i] = 1;
    }
}

逆元求组合数取模

最后更新于

这有帮助吗?