Data Structures & AlgorithmsVery hardCodeforces Div2 C · extended Euclid

Problem: Which pair (x, y) satisfies 240x + 46y = gcd(240, 46)?

  1. A. (-9, 47)
  2. B. (-9, 46)
  3. C. (7, -36)
  4. D. (-2, 9)

Correct answer: A. (-9, 47)

gcd(240, 46) = 2 and 240 * (-9) + 46 * 47 = -2160 + 2162 = 2. The extended Euclidean algorithm produces such a pair, and the other options fail the equation.

More Coding Interview Problems questions

Exams that ask this topic