summaryrefslogtreecommitdiff
path: root/math/shortModInv.cpp
diff options
context:
space:
mode:
authorLucas Schwebler <lucas.schwebler@gmail.com>2023-11-15 17:19:47 +0100
committerLucas Schwebler <lucas.schwebler@gmail.com>2023-11-15 17:19:47 +0100
commite5676ef4ad6652ea794aac5d10ce8b65b20e9351 (patch)
treeed767c455e4ab59b32132d0635539071ced328d4 /math/shortModInv.cpp
parenta7f4c162112a1f80b823984baa0c737df9a7f5e0 (diff)
add shortModInv and /usr/bin/time -v
Diffstat (limited to 'math/shortModInv.cpp')
-rw-r--r--math/shortModInv.cpp3
1 files changed, 3 insertions, 0 deletions
diff --git a/math/shortModInv.cpp b/math/shortModInv.cpp
new file mode 100644
index 0000000..747eb7a
--- /dev/null
+++ b/math/shortModInv.cpp
@@ -0,0 +1,3 @@
+ll inv(ll a, ll b){ // a^{-1} mod b
+ return 1 < a ? b - inv(b % a, a) * b / a : 1;
+} \ No newline at end of file