Data Structures & AlgorithmsVery hardCodeforces Div2 B-D · ICPC regional

What is the total number of 1-bits in the binary representations of all integers from 0 to 31 inclusive?

  1. A. 80
  2. B. 81
  3. C. 75
  4. D. 82

Correct answer: A. 80

Each bit position is set in exactly half of the 32 numbers, so the total is 5 times 16 = 80. The bitwise formula gives the same answer.

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

Exams that ask this topic