GATE Computer ScienceHardGATE CS (PYQ pattern)

How many non-empty subsets of {3, 5, 6, 7, 9, 11, 13, 14} have an element sum divisible by 10?

  1. A. 26
  2. B. 24
  3. C. 25
  4. D. 22

Correct answer: C. 25

Counting subsets by sum modulo 10 with a DP (or listing all 256 subsets) gives 26 subsets including the empty one, i.e. 25 non-empty ones (e.g. {3, 7}, {6, 14}, {5, 6, 9}, …, sums 10, 20, 30, 40, 50, 60). Counting the empty set gives 26; 256/10 ≈ 25.6 is only a heuristic.

More Algorithms questions

Exams that ask this topic