long long pow_mod(long long x, long long n, long long mod) { long long res = 1; while (n) { if (n & 1) res = res * x % mod; x = x * x % mod; n >>= 1; } return res; } long long fac[Max]; long long n, m, p; int main() { while (~scanf("%lld %lld", &n, &m)) { p=1e9+7; fac[0] = 1; for (int i = 1; i <= n; i++) {fac[i] = fac[i - 1] * i % p;} //组合数 = n!*(m!%p的逆元)*((n-m)!%p的逆元)%p printf("%lld\n", fac[n] * pow_mod(fac[m], p - 2, p) % p * pow_mod(fac[n - m], p - 2, p) % p); } }
原文地址:https://www.cnblogs.com/ww123/p/9402302.html
时间: 2024-10-17 08:39:04