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.

  1. A. 63
  2. B. 54
  3. C. 66
  4. 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

Exams that ask this topic