Code
Hub
Workspaces
Following
Trending
Connect
MCP
copy
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"
2
pair<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
check
Function · 0.85
Calls
2
egcd
Function · 0.85
smod
Function · 0.85
Tested by
1
check
Function · 0.68