Data Structures & AlgorithmsVery hardICPC regional · Digit DP warm-up
Problem: Count the integers x with 1 <= x <= 1000 whose decimal digits sum to exactly 10.
- A. 63
- B. 54
- C. 66
- D. 81
Correct answer: A. 63
Unrestricted stars and bars over three digits gives C(12,2) = 66, but that counts digit tuples with a digit of 10 or more, namely (10,0,0) and its 2 permutations. Subtracting those 3 gives 63.
More Coding Interview Problems questions
- Problem: Modulo the prime p = 998244353, which value is the multiplicative inverse of 2, i.e. the x in [0, p) with 2x ≡ 1 (mod p)?
- Problem: A product of 11 matrices A1 A2 ... A11 is evaluated by choosing a full parenthesisation. How many different parenthesisations are…
- Problem: n = 10 people stand in a circle and every 3rd person is removed until one remains (counting starts at person 1 and the removed…
- Problem: Compute F(100) mod 1000 where F(0) = 0, F(1) = 1 and F(n) = F(n-1) + F(n-2). python def mul(A, B, m): return [[sum(A[i][k]…
- Problem: Count the inversions of the array [3, 1, 4, 1, 5, 9, 2, 6], where an inversion is a pair of positions i < j with a[i] > a[j]…
- Problem: Huffman coding is applied to symbol frequencies 5, 9, 12, 13, 16, 45, always merging the two smallest weights. What is the total…