summaryrefslogtreecommitdiff
path: root/math/shortModInv.cpp
diff options
context:
space:
mode:
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