Mathematics (JEE)HardCodeforces Div2 D

How many subsets of {1, 2, ..., 12} (including the empty set) contain no two elements whose difference is 1 or 2?

  1. A. 4096
  2. B. 377
  3. C. 128
  4. D. 129

Correct answer: D. 129

With a(n) for subsets of {1..n}: either n is absent, giving a(n-1), or n is present and n-1, n-2 are absent, giving a(n-3). With a(0)=1, a(1)=2, a(2)=3 this gives a(12) = 129.

More Permutations, Combinations and Probability questions

Exams that ask this topic