Skip to main content

Chinese Remainder

Challenge on lesson: Checkpoint — CRT

CHALLENGE
Difficulty: advanced+25 XP

**Problem.** 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. **Constraints:** 1 ≤ q ≤ 100; 2 ≤ n, m < 10^5; gcd(n, m) = 1; 0 <= a < n; 0 <= b < m. Extended-Euclid inverse per query; the W answers only the second congruence.

Back to lesson: Checkpoint — CRT