diff options
-rw-r--r-- | Math/numtheory.cpp | 2 | ||||
-rw-r--r-- | Math/primes.cpp | 8 |
2 files changed, 6 insertions, 4 deletions
diff --git a/Math/numtheory.cpp b/Math/numtheory.cpp index b211282..d25a984 100644 --- a/Math/numtheory.cpp +++ b/Math/numtheory.cpp @@ -1,5 +1,6 @@ constexpr ll MOD = 1e9+7; + inline ll pw(ll base, ll exp) { ll res = 1; while (exp) { @@ -14,4 +15,5 @@ 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+1ll)*fact[i]%MOD, ifact[i+1] = inv(fact[i+1]); diff --git a/Math/primes.cpp b/Math/primes.cpp index 882cae9..0647155 100644 --- a/Math/primes.cpp +++ b/Math/primes.cpp @@ -33,7 +33,7 @@ vector<ii> factorize(ll N) { ll num_pf(ll N) { ll idx = 0, pf = pr[idx], ans = 0; - while (N != 1 && pf * pf <= N)) { + while (N != 1 && pf * pf <= N) { while (N % pf == 0) { N /= pf; ans++; } pf = pr[++idx]; } @@ -52,7 +52,7 @@ ll num_diff_pf(ll N) { ll sum_pf(ll N) { ll idx = 0, pf = pr[idx], ans = 0; - while (N != 1 && pf * pf <= N)) { + while (N != 1 && pf * pf <= N) { while (N % pf == 0) { N /= pf; ans += pf; } pf = pr[++idx]; } @@ -61,7 +61,7 @@ ll sum_pf(ll N) { ll num_div(ll N) { ll idx = 0, pf = pr[idx], ans = 1; - while (N != 1 && pf * pf <= N)) { + while (N != 1 && pf * pf <= N) { ll power = 0; while (N % pf == 0) { N /= pf; ++power; } ans *= (power + 1); @@ -90,4 +90,4 @@ ll phi(ll N) { pf = pr[++idx]; } return N != 1 ? ans - ans / N : ans; -}
\ No newline at end of file +} |