UVa 10931

From Algorithmist
Jump to navigation Jump to search

10931 - Parity[edit]

Summary[edit]

Figure out how many 1's are in a binary number for the decimal number they give you.

Explanation[edit]

  • This is most easily done by keeping track of the 1's and continuously bitshifting until the number is 0.
  • The constraints are 31 bits of all 1's 2^31-1 so just integer will suffice.

Solutions[edit]

References[edit]