Data Structures & AlgorithmsVery hardCodeforces Div2 C · extended Euclid
Problem: Which pair (x, y) satisfies 240x + 46y = gcd(240, 46)?
- A. (-9, 47)
- B. (-9, 46)
- C. (7, -36)
- 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
- Problem: Cows must be placed in stalls at positions [1, 2, 4, 8, 9] so that the minimum distance between any two cows is as large as…
- Problem: Trains arrive at times [900, 940, 950, 1100, 1500, 1800] and depart at [910, 1200, 1120, 1130, 1900, 2000]. The two-pointer code…
- Problem: Return, for each index i, the product of all other elements (no division allowed). Print the list for a = [2, 3, 4, 5]. python a…
- Problem: How many distinct non-empty substrings does the string 'abab' contain? python s = 'abab' print(len({s[i:j] for i in range(len(s))…
- Problem: What is the maximum XOR of any two different elements of the array [3, 10, 5, 25, 2, 8]? python a = [3, 10, 5, 25, 2, 8]…
- Problem: What is the length of the longest contiguous subarray containing at most two distinct values? python from collections import…