欢迎各大高手前来做题
WACMIAN NUMBERS In the supposedly uninhabited Wacmahara Desert, a tribe of unusual people has
been discovered. The Wacmians have only 2 fingers and a thumb on each hand,
and have invented their own numbering system. The digits they use and the
symbols they use for digits are quite unusual, but anthropologists have been able
to represent them as follows:
% represents 0
) represents 1
~ represents 2
@ represents 3
? represents 4
\ represents 5
$ represents -1 (yes, they even have a negative digit)
As you may expect, their system is base 6 where each place value is 6 times the
value to its right, as in the following examples:
)@% is 1*6*6+3*6+0 = 36+18+0 = 54
?$~~ is 4*6*6*6+(–1)*6*6+2*6+2 = 864–36+12+2 = 842
$~~ is (–1)*6*6+2*6+2 = –36+12+2 = -22
Your task is to take Wacmian numbers and represent them as standard base 10
numbers.
INPUT FORMAT
Input consists of Wacmian numbers, one per line. Each number consists of a
sequence of 1 to 10 Wacmian digits. A single ‘#’ on a line by itself indicates the
end of input.
SAMPLE INPUT:
)@%
?$~~
$~~
%
#
OUTPUT FORMAT
Output will be the corresponding decimal numbers, one per line.
SAMPLE OUTPUT:
54
842
-22
0