Data Structures & AlgorithmsVery hardICPC regional · number theory
Problem: Which statement about the 'Chinese remainder theorem' is correct for non-coprime moduli?
- A. A solution always exists
- B. A solution exists iff the congruences agree modulo the gcd of each pair
- C. The solution is always zero
- 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
- Problem: What is the complexity of computing the Euler totient for all numbers up to n with a linear sieve?
- Problem: Which technique computes the sum of a function over all subsets of a set of size n in O(n 2^n)?
- Problem: What does the cross product of two 2D vectors (a, b) and (c, d) equal?
- Problem: Which approach finds the k-th lexicographically smallest substring of a string?
- Problem: What is the expected number of distinct values when n balls are thrown uniformly into n bins?
- Problem: Which algorithm is the standard way to find the minimum number of swaps to sort a permutation?