MCPcopy Create free account
hub / github.com/SuprDewd/CompetitiveProgramming / linear_congruence

Function linear_congruence

code/mathematics/linear_congruence.cpp:2–5  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "egcd.cpp"
2pair<ll,ll> linear_congruence(ll a, ll b, ll n) {
3 ll x, y, d = egcd(smod(a,n), n, x, y);
4 if ((b = smod(b,n)) % d != 0) return ii(0,0);
5 return make_pair(smod(b / d * x, n),n/d); }
6// vim: cc=60 ts=2 sts=2 sw=2:

Callers 1

checkFunction · 0.85

Calls 2

egcdFunction · 0.85
smodFunction · 0.85

Tested by 1

checkFunction · 0.68