Uvs-575 Skew Binary
Time Limit:3000 MS |
|
Memory Limit:Unknown |
|
64bit IO Format:% Lld & % llu |
Submit Status Description
When a number is expressed in decimal,K-Th digit represents a multiple of 10K. (Digits are numbered from right to left, where the least significant digit is number 0.) For example,
When a number is expressed in binary,K-Th digit represents a multiple of 2K. For example,
InSkew binary,K-Th digit represents a multiple of 2K+ 1-1. The only possible digits are 0 and 1, cannot t that the least-significant nonzero digit can be a 2. For example,
The first 10 numbers in skew binary are 0, 1, 2, 10, 11, 12, 20,100,101, and 102. (Skew binary is useful in some applications because it is possible to add 1 with at most one carry. however, this has nothing to do with the current problem .) InputThe input file contains one or more lines, each of which contains an integerN. IfN= 0 it signals the end of the input, and otherwiseNIs a nonnegative integer in skew binary. OutputFor each number, output the decimal equivalent. The decimal valueNWill be at most 2 31-1 = 2147483647. Sample Input1012020000000000000000000000000000010100000000000000000000000000000011100111110000011100001011011020000 Sample Output44214748364632147483647471041110737 Miguel A. Revilla 1998-03-10Source Root: Competitive Programming 2: This increases the lower bound of Programming Contests. Again (Steven & Felix Halim): Mathematics: Ad Hoc Mathematics Problems: Base Number Variants Root: aoapc I: Beginning Algorithm Contests (Rujia Liu): Volume 1. Elementary Problem Solving: Maths-Number Theory Root: Competitive Programming 3: The New Lower Bound of Programming Contests (Steven & Felix Halim): Mathematics: Ad Hoc Mathematics Problems: Base Number Variants |