Data Structures & AlgorithmsHardICPC regional · Codeforces Div2 B

Problem: The array [1, 2, 4, 8, 16, 32] stores powers of two. For how many pairs (i < j) is a[i] + a[j] a power of two?

  1. A. 1
  2. B. 0
  3. C. 2
  4. D. 3

Correct answer: B. 0

Two distinct powers of two set two different bits, so their sum has exactly two set bits and is never a power of two. The brute-force count is therefore zero.

More Coding Interview Problems questions

Exams that ask this topic