组合数

计算组合数C(N, M).C(N, M) = N! / (M! * (N - M)!)

代码:

typedef long long LL;
LL C(int n, int m) {
    if(m < n - m) m = n - m;
    LL ans = 1;
    for(int i = m + 1; i <= n; i++) ans *= i;
    for(int i = 1; i <= n - m; i++) ans /= i;
    return ans;
}
原文地址:https://www.cnblogs.com/Ash-ly/p/5736322.html