2282. The famous Supercomputer C-23

单点时限: 2.0 sec

内存限制: 256 MB

A Long time ago in a galaxy far, far away the C-23, a very powerful Supercomputer, was developed. An expedition of astronauts was sent out to boldly go to this galaxy and retrieve this famous piece of technology. Fortunately, they encountered no enemies in this galaxy because the inhabitants destroyed themselves thousands of years ago. Unfortunately, the astronauts weren’t able to use the C-23 because its internal computations aren’t based to 10 or 2 but to the base 23. So it became necessary for the astronauts to translate numbers to and from this base to the well-known decimal base. This is just the point where you as computer specialist of this expedition come in…

Your job is to write a program that can translate numbers given in the internal representation of the C-23 into ordinary decimal numbers and vice versa. A number in C-23 represantation is preceded by a “#”-sign. The Command “C23” takes a decimal number and translates it to a C-23 number. The Command “DEC” gets a C-23 number and converts it to a decimal number.

For example, if you encounter a command like “C23 66” your program should print the corresponding C-23 value (#2K). If you encounter a command like “DEC #I” your program should print the corresponding decimal value (18).


The first line of input contains the number of test cases n. Then follow n lines of commands in the format described above. Every number that occurs in the test cases is an integer between 0 and 2,000,000,000 (both inclusive).


For each command your program should print the translated number on a single line. Don’t forget to put a leading “#”-sign before the numbers in C-23 representation.


DEC #42
C23 42
C23 23

20 人解决,26 人已尝试。

31 份提交通过,共有 134 份提交。

5.0 EMB 奖励。

创建: 13 年,11 月前.

修改: 4 年,10 月前.

最后提交: 7 月前.

来源: Freshman Programming Contest