TopCoder

User's AC Ratio

NaN% (0/0)

Submission's AC Ratio

NaN% (0/0)

Tags

Description

The Great Sand Council (GSC) of the planet Phleebutt (apologies to Sierra) have devised a base
3 number system to suit their physiology. The symbols used to represent the three valid digits
of their number system are ‘0’, ‘1’, and ‘-’, following the unusual configuration of their hands
(don’t ask). The decimal counterparts of the three symbols are, respectively, 0, 1 and −1.



Each position in a number has a value three times greater than the position immediately to its
right. For example, the number ‘10-’ has the value 8 in decimal, since 1 × 9 + 0 × 3 + (−1)× = 8.



Similarly, the number ‘-1’ has the decimal value −2, since (−1)×3+1 = −2. GSC representations
of integers never start with a digit of zero, except for ‘0’ (a single zero) which has the decimal
value 0.



You have to write a program that can convert 32-bit signed decimal integers into their equivalent
GSC representations.

Input Format

Your program will receive a list of integers as input. Each integer will appear in a separate line
and be between −231 and 231 − 1. The end of list is indicated by the end of file.

Output Format

You have to echo the input numbers followed by their GSC representations, as shown in the
Sample Output (including all extra symbols).

Sample Input 1

10
2
-17
42
1024

Sample Output 1

10 = 101 GSC
2 = 1- GSC
-17 = -101 GSC
42 = 1---0 GSC
1024 = 111-0-1 GSC

Hints

Problem Source

Migrated from old NTUJ.

Subtasks

No. Testdata Range Score

Testdata and Limits

No. Time Limit (ms) Memory Limit (VSS, KiB) Output Limit (KiB) Subtasks
0 10000 65536 200