Data Structures & AlgorithmsHardICPC regional · number theory
Problem: What is the sum of all divisors of 360 = 2^3 * 3^2 * 5?
- A. 1080
- B. 1404
- C. 1170
- D. 1000
Correct answer: C. 1170
Multiplicativity gives sigma(360) = (2^4 - 1)/(2 - 1) * (3^3 - 1)/(3 - 1) * (5^2 - 1)/(5 - 1) = 15 * 13 * 6 = 1170. Using 2^3 instead of 2^4 - 1 is a classic slip.
More Coding Interview Problems questions
- Problem: Find the smallest positive x satisfying x ≡ 2 (mod 3), x ≡ 3 (mod 5) and x ≡ 2 (mod 7).
- Problem: Which pair (x, y) satisfies 240x + 46y = gcd(240, 46)?
- 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))…