diff options
author | Anthony Wang | 2021-06-12 10:24:47 -0500 |
---|---|---|
committer | Anthony Wang | 2021-06-12 10:24:47 -0500 |
commit | 363f03806dfd977d8a76a1270317285398817c60 (patch) | |
tree | 506593db65637cef5bcf7077c489e03058f99fa9 /Math | |
parent | a52573369c631ad40b3266ade1c69039d92a9a6b (diff) |
Update numtheory
Diffstat (limited to 'Math')
-rw-r--r-- | Math/numtheory.cpp | 4 |
1 files changed, 1 insertions, 3 deletions
diff --git a/Math/numtheory.cpp b/Math/numtheory.cpp index a47a385..282e39f 100644 --- a/Math/numtheory.cpp +++ b/Math/numtheory.cpp @@ -1,6 +1,5 @@ constexpr ll MOD = 1e9+7; - inline ll pw(ll base, ll exp) { ll res = 1; while (exp) { @@ -12,8 +11,7 @@ inline ll pw(ll base, ll exp) { inline ll inv(ll x) { return pw(x, MOD-2); } ll fact[MX] = { 1 }, ifact[MX] = { 1 }; - inline 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+1)*fact[i]%MOD, ifact[i+1] = inv(fact[i+1]); +for (int i = 1; i < N; ++i) fact[i] = i*fact[i-1]%MOD, ifact[i] = inv(fact[i]); |