#P10462. Number Base Conversion

Number Base Conversion

题目描述

Write a program to convert numbers in one base to numbers in a second base. There are 6262 different digits:

{09,AZ,az}\{ 0\sim 9, A\sim Z,a\sim z \}

HINT: If you make a sequence of base conversions using the output of one conversion as the input to the next, when you get back to the original base, you should get the original number.

输入格式

The first line of input contains a single positive integer. This is the number of lines that follow. Each of the following lines will have a (decimal) input base followed by a (decimal) output base followed by a number expressed in the input base. Both the input base and the output base will be in the range from 22 to 6262. That is (in decimal) $A = 10, B = 11, \dots, Z = 35, a = 36, b = 37, \dots, z = 61$ (090\sim 9 have their usual meanings).

输出格式

The output of the program should consist of three lines of output for each base conversion performed. The first line should be the input base in decimal followed by a space then the input number (as given expressed in the input base). The second output line should be the output base followed by a space then the input number (as expressed in the output base). The third output line is blank.

题目大意

【题目描述】

编写一个程序,将一个进制中的数字转换为另一个进制中的数字。有 6262 个不同的数字:

09,AZ,az{ 0\sim 9, A\sim Z,a\sim z }

提示:如果你连续进行一系列的进制转换,将一个转换的输出作为下一个转换的输入,当你回到原始的进制时,你应该得到原始的数字。

【输入格式】

输入的第一行包含一个正整数,表示接下来有多少行输入。接下来的每一行都包含一个输入进制(十进制表示)和一个输出进制(十进制表示),然后是以输入进制表示的数字。输入进制和输出进制都将在 226262 的范围内。也就是说(十进制表示)$A = 10, B = 11, \dots, Z = 35, a = 36, b = 37, \dots, z = 61$,(090\sim 9 的意思与平常一样)。

【输出格式】

程序的输出应该包括每次进制转换的三行输出。第一行应该是以十进制表示的输入进制,然后是一个空格,接着是以输入进制表示的输入数字。第二行输出是输出进制,然后是一个空格,接着是以输出进制表示的输入数字。第三行输出是空白行。

翻译来自于:ChatGPT。

8
62 2 abcdefghiz
10 16 1234567890123456789012345678901234567890
16 35 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2
35 23 333YMHOUE8JPLT7OX6K9FYCQ8A
23 49 946B9AA02MI37E3D3MMJ4G7BL2F05
49 61 1VbDkSIMJL3JjRgAdlUfcaWj
61 5 dl9MDSWqwHjDnToKcsWE1S
5 10 42104444441001414401221302402201233340311104212022133030
62 abcdefghiz
2 11011100000100010111110010010110011111001001100011010010001

10 1234567890123456789012345678901234567890
16 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2

16 3A0C92075C0DBF3B8ACBC5F96CE3F0AD2
35 333YMHOUE8JPLT7OX6K9FYCQ8A

35 333YMHOUE8JPLT7OX6K9FYCQ8A
23 946B9AA02MI37E3D3MMJ4G7BL2F05

23 946B9AA02MI37E3D3MMJ4G7BL2F05
49 1VbDkSIMJL3JjRgAdlUfcaWj

49 1VbDkSIMJL3JjRgAdlUfcaWj
61 dl9MDSWqwHjDnToKcsWE1S

61 dl9MDSWqwHjDnToKcsWE1S
5 42104444441001414401221302402201233340311104212022133030

5 42104444441001414401221302402201233340311104212022133030
10 1234567890123456789012345678901234567890