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

Function crt

code/mathematics/crt.cpp:2–6  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1#include "egcd.cpp"
2ll crt(vector<ll> &as, vector<ll> &ns) {
3 ll cnt = size(as), N = 1, x = 0, r, s, l;
4 rep(i,0,cnt) N *= ns[i];
5 rep(i,0,cnt) egcd(ns[i], l = N/ns[i], r, s), x += as[i]*s*l;
6 return smod(x, N); }
7pair<ll,ll> gcrt(vector<ll> &as, vector<ll> &ns) {
8 map<ll,pair<ll,ll> > ms;
9 rep(at,0,size(as)) {

Callers 2

testFunction · 0.85
gcrtFunction · 0.85

Calls 2

egcdFunction · 0.85
smodFunction · 0.85

Tested by 1

testFunction · 0.68