Data Structures & AlgorithmsHardCodeforces Div2 B-D · ICPC regional

How many integers from 1 to 64 inclusive are either a power of two or have exactly two 1-bits in binary?

  1. A. 22
  2. B. 23
  3. C. 7
  4. D. 14

Correct answer: A. 22

Powers of two up to 64 number 7, and the numbers up to 64 with exactly two 1-bits number 15; the two sets are disjoint, so the union has 22 elements.

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

Exams that ask this topic