Data Structures & AlgorithmsVery hardICPC regional · number theory

Problem: Which statement about the 'Chinese remainder theorem' is correct for non-coprime moduli?

  1. A. A solution always exists
  2. B. A solution exists iff the congruences agree modulo the gcd of each pair
  3. C. The solution is always zero
  4. D. It only works for prime moduli

Correct answer: B. A solution exists iff the congruences agree modulo the gcd of each pair

For general moduli, consistency is checked pairwise via gcds before combining.

More Coding Interview Problems questions

Exams that ask this topic