On the Subject of CRT
yo phone linging
- Each screen has a modulo number and a remainder.
- Write down all modulus and all remainders.
- Compile arrays M (for modulus) and R (for remainders).
- Assign A=M[0], Z=R[0], i=1.
- Find x (in range (0..M[i]-1)), such that: (A*x+Z)%M[i] == R[i].
- Assign A=A*x+Z, Z=R[i], i=i+1.
- If i==M.length, submit A. Else return to step 2.
Notice: if lcd(M[0],...,M[i-1],M[i]) == lcd(M[0],...,M[i-1]), you can safely disregard screen with M[i].