diff options
author | Ta180m | 2020-07-13 10:55:06 -0500 |
---|---|---|
committer | Ta180m | 2020-07-13 10:55:06 -0500 |
commit | 3014121f4d501983b8b81e855a85997991d30f2d (patch) | |
tree | aed1635c30f8d44afaa43b7800b68f8f4dd4d926 /Math | |
parent | 345ad1ac38ff571849b4b5830bcfb1a481af1d2c (diff) |
Update numtheory.cpp
Diffstat (limited to 'Math')
-rw-r--r-- | Math/numtheory.cpp | 14 |
1 files changed, 7 insertions, 7 deletions
diff --git a/Math/numtheory.cpp b/Math/numtheory.cpp index 4b9f029..3396a0e 100644 --- a/Math/numtheory.cpp +++ b/Math/numtheory.cpp @@ -1,19 +1,19 @@ constexpr ll MOD = 1e9+7; -int fact[200002] = { 1 }, ifact[200002] = { 1 }; +ll fact[200002] = { 1 }, ifact[200002] = { 1 }; -int pw(int base, int exp) { - int res = 1; +ll pw(ll base, ll exp) { + ll res = 1; while (exp) { - if (exp & 1) res = (ll)base * res % MOD; - exp >>= 1, base = (ll)base * base % MOD; + if (exp & 1) (res *= base) %= MOD; + exp >>= 1, (base *= base) %= MOD; } return res; } -int inv(int x) { return pw(x, MOD - 2); } +ll inv(ll x) { return pw(x, MOD - 2); } -int nCr(int n, int k) { return (ll)fact[n] * ifact[k] % MOD * ifact[n - k] % MOD; } +ll nCr(int n, int k) { return fact[n] * ifact[k] % MOD * ifact[n - k] % MOD; } for (int i = 0; i < N; ++i) { fact[i + 1] = (i + 1ll) * fact[i] % MOD; |