Negative Binary
InterviewTime limit1sMemory limit128 MB
Convert each given decimal integer to its base negative two representation without leading zeros.
- Level
Easy3 of 10
- Topics
- Math, Implementation
- Solved
- No attempts yet
Problem
In positional notation the rightmost place value is , and every step to the left multiplies it by the base once more, giving , , and so on. With base the place values read from right to left. Counting up from 1 therefore goes 1, 110, 111, 100, 101, 11010, 11011, 11000, 11001, and so on.
Base represents a negative number without a separate sign bit. Write a program that prints the decimal number in base .
Input
The first line has a positive integer , the number of test cases, with .
Each of the next lines has one integer with .
Output
For each test case print one line in the format Case #x: M, where is the case number starting from 1 and is the base representation of .
carries no leading zero. When , print 0.