Problem F
Base i-1
Input: Standard Input
Output: Standard Output
|
A complex system that
works is invariably found |
John
Gaule
Everyone knows about base-2
(binary) integers and base-10 (decimal) integers, but what about base i-1?
A complex integer n has the form
n = b0
+ b1(i-1) + b2(i-1)2
+ b3(i-1)3 + ...
The cool thing is that every complex integer has a unique base-(i-1) representation, 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
is a line containing a complex integer a+bi as
a pair of integers, a and b. Both a
and b will be in the range from
For each test case, output one line containing "Case #x:" followed by the same complex integer, written in base i-1 with no leading zeros.
41 02 311 00 0 |
Case #1: 1Case #2: 1011Case #3: 111001101
Case #4: 0 |
Problem setter: Igor Naverniouk
Special Thanks: Shahriar Manzoor