Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

How many index pairs i < j in [12, 21, 30, 43, 66, 111, 3] have equal decimal digit sums?

  1. A. 10
  2. B. 15
  3. C. 21
  4. D. 5

Correct answer: A. 10

Digit sums are 3, 3, 3, 7, 12, 3, 3; the five 3s give C(5,2) = 10 equal pairs. Using the repeated digital root makes 66 (12 → 3) join the group: C(6,2) = 15. 21 counts all pairs and 5 is the group size, not its pairs.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic