UVa 575

From Algorithmist

Jump to: navigation, search

Contents

[edit] 575 - Skew Binary

[edit] Summary

Convert a number from base 2k + 1 - 1 to decimal.

[edit] Explanation

Standard base-conversion to decimal. Start at the Least Significant Bit (LSB) and work your way to the Most Significant Bit (MSB).

[edit] Gotcha's

  • Input of 0 terminates.

[edit] Notes

  • The output will fit nicely into a 32-bit int.

[edit] Input

10120
200000000000000000000000000000
10
1000000000000000000000000000000
11
100
11111000001110000101101102000
0

[edit] Output

44
2147483646
3
2147483647
4
7
1041110737
Personal tools