Chinese remainder theorem

Write codeHard35 minCitadel style

Your task

Given pairwise-coprime moduli and corresponding remainders, find the smallest non-negative x satisfying x = remainders[i] (mod moduli[i]) for all i, using the Chinese Remainder Theorem. Return a two-element list [x, M] where M is the product of all moduli and x is the unique solution in [0, M). Constraints: 1 to 10 congruences, each modulus 1 <= moduli[i] <= 1000, moduli are pairwise coprime, 0 <= remainders[i] < moduli[i].

Examples

crt(remainders: list[int], moduli: list[int]) -> list[int]
Example 1
Inputcrt([2, 3, 2], [3, 5, 7])
Output[23, 105]