2547. Base i-1

单点时限: 2.0 sec

内存限制: 256 MB

You must have come across base 2 (binary) and base 10 (decimal) integers, but what about base i-1? A complex integer n has the form n=a+bi, where a and b are integers, and i is the square root of -1 (which means that i2=-1). A complex integer n written in base (i-1) is a sequence of digits (bi), writen right-to-left, each of which is either 0 or 1 (no negative or imaginary digits!), and the following must hold.

n = b0 + b1(i-1) + b2(i-1)2 + b3(i-1)3 + …

Each complex integer can be expressed in base-(i-1) in a unique way with no minus sign required. Your task is to find this representation.

输入格式

The first line of input gives the number of cases, N (at most 20000). N test cases follow. Each one contains a complex integer a+bi as a pair of integers, a and b. -1,000,000< a,b < 1,000,000.

输出格式

For each test case, output one line containing “Case #x:” followed by a complex integer in the form of a + bi, expressed in base i-1 with no leading zeros.

样例

Input
4
0 0
0 1
1 0
5 9
Output
Case #1: 0
Case #2: 11
Case #3: 1
Case #4: 111010011110

7 人解决,26 人已尝试。

7 份提交通过,共有 44 份提交。

8.2 EMB 奖励。

创建: 15 年,3 月前.

修改: 6 年,10 月前.

最后提交: 3 年,1 月前.

来源: partychen

题目标签