UVa 10931

From Algorithmist
Jump to: navigation, search

Contents

[edit] 10931 - Parity

[edit] Summary

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

[edit] Explanation

  • 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.

[edit] References

Personal tools
Namespaces
Variants
Actions
Navigation
Toolbox