summaryrefslogtreecommitdiff
path: root/content/math/linearCongruence.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'content/math/linearCongruence.cpp')
-rw-r--r--content/math/linearCongruence.cpp5
1 files changed, 5 insertions, 0 deletions
diff --git a/content/math/linearCongruence.cpp b/content/math/linearCongruence.cpp
new file mode 100644
index 0000000..cdb5a37
--- /dev/null
+++ b/content/math/linearCongruence.cpp
@@ -0,0 +1,5 @@
+ll solveLinearCongruence(ll a, ll b, ll m) {
+ ll g = gcd(a, m);
+ if (b % g != 0) return -1;
+ return ((b / g) * multInv(a / g, m / g)) % (m / g);
+}