Arbitrary Bases

Problem #90

Tags: computing

Who solved this?

Previous:Hexadecimal Numbers Next:Binary Fractions


Now that you know how to convert numbers to Binary and Hexadecimal, you may already be wondering on your own what other bases are possible. Indeed, it is possible to express any number in any given positive integer base, provided that you have enough characters to use as digits. By utilizing every digit 0-9 and every English letter a-z, we could implement up to a Base-36 counting system! And now that we see that there's nothing particularly special about our Base-10 Decimal system, we shouldn't be afraid to convert values from any given base into any other given base.

Problem Statement

Input Data
First line will be Q, the quantity of testcases.
Q lines will then follow, each in the format V B1 B2 where V is a value expressed in base B1, which you will be expected to convert into base B2.

Answer
Should consist of Q space-separated values, corresponding to each value V converted into base B2.
Please do not use prefixes such as 0b or 0x for this problem.

Example

input data:
2
fa50 16 2
10tot 35 36

answer:
1111101001010000 wxyz
You need to login to get test data and submit solution.