CP Python LibraryGitHub

Chinese Remainder Theorem

Solves the system of congruences:

xR0(modM0)xR1(modM1)xRn1(modMn1)\begin{aligned} x &\equiv R_0 \pmod{M_0} \\ x &\equiv R_1 \pmod{M_1} \\ &\vdots \\ x &\equiv R_{n-1} \pmod{M_{n-1}} \end{aligned}

given two arrays RR and MM of length nn.

crt

Arguments

Returns

Complexities

Code Test