Data Structures & AlgorithmsModerateCodeforces Div 2 C · ICPC regional

How many integers x with 1 <= x <= 200 have an odd number of 1-bits in their binary representation?

  1. A. 101
  2. B. 99
  3. C. 100
  4. D. 128

Correct answer: A. 101

Brute force over 1..200 finds 101 numbers with an odd popcount (the 'evil/odious' split is not exactly half here). Counting even popcounts gives 99, stopping at 199 or assuming an exact half gives 100, and 128 is half of 0..255.

More Coding Interview Problems questions

Exams that ask this topic