Skip to main content
๐Ÿ“œ WAYPOINT LESSON

Checkpoint โ€” CRT

โญ beginnerโณ 40 min read๐Ÿ“ Lesson 172 of 281

One hundred two-congruence systems graded exactly; a wrong answer that reads only the second congruence is the graded failure.

Checkpoint โ€” CRT. Line 1: q. Each line: a n b m with gcd(n, m) = 1. Print x with x = a (mod n) and x = b (mod m), 0 <= x < n*m.

x = a + n*t; t = (b - a) * n^(-1) (mod m) โ€” the inverse via extended Euclid (m need not be prime).