Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

How many integers from 1 to 1000 inclusive are divisible by 8 and have an even number of 1-bits in binary?

  1. A. 63
  2. B. 125
  3. C. 500
  4. D. 62

Correct answer: D. 62

Enumerate multiples of 8 (125 of them) and test the parity of their popcount. Multiplying the count by a probability of one half is only an estimate.

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

Exams that ask this topic