summaryrefslogtreecommitdiff
path: root/math/binomial2.cpp
diff options
context:
space:
mode:
authorGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
committerGloria Mundi <gloria@gloria-mundi.eu>2024-11-16 01:24:14 +0100
commit98567ec798aa8ca2cfbcb85c774dd470f30e30d4 (patch)
tree5113d5cc24d1ad5f93810b6442ce584a36950dc8 /math/binomial2.cpp
parentad3856a6b766087df0036de0b556f4700a6498c9 (diff)
parent8d11c6c8213f46f0fa19826917c255edd5d43cb1 (diff)
mzuenni tests
Diffstat (limited to 'math/binomial2.cpp')
-rw-r--r--math/binomial2.cpp32
1 files changed, 0 insertions, 32 deletions
diff --git a/math/binomial2.cpp b/math/binomial2.cpp
deleted file mode 100644
index 4531505..0000000
--- a/math/binomial2.cpp
+++ /dev/null
@@ -1,32 +0,0 @@
-constexpr ll mod = 1'000'000'009;
-
-ll binomPPow(ll n, ll k, ll p) {
- ll res = 1;
- if (p > n) {
- } else if (p > n - k || (p * p > n && n % p < k % p)) {
- res *= p;
- res %= mod;
- } else if (p * p <= n) {
- ll c = 0, tmpN = n, tmpK = k;
- while (tmpN > 0) {
- if (tmpN % p < tmpK % p + c) {
- res *= p;
- res %= mod;
- c = 1;
- } else c = 0;
- tmpN /= p;
- tmpK /= p;
- }}
- return res;
-}
-
-ll calc_binom(ll n, ll k) {
- if (k > n) return 0;
- ll res = 1;
- k = min(k, n - k);
- for (ll i = 0; primes[i] <= n; i++) {
- res *= binomPPow(n, k, primes[i]);
- res %= mod;
- }
- return res;
-}