Even though computers operate using Binary, that is not the counting
system that programmers are most familiar with. The smallest unit of information
in a computer is the bit, which is a single Binary digit either 0 or 1.
Using only four bits, we could represent every integer from zero (0b0000) to fifteen (0b1111) in Base-2.
However, wouldn't it be convenient if instead we used a system where all possible configurations of four bits could be represented by a single character? This is the primary motivation for instead expressing numbers in Base-16, or Hexadecimal, allowing for chunks of binary data to be expressed using only one-fourth the required characters.
So how do we express the numbers 10, 11, 12, 13, 14, 15 with single
digits instead of two? Let's add some new digits, which we will write
as the letters a=10, b=11, c=12, d=13, e=14, f=15. Just as with the other
counting bases, once we exceed our highest digit f then that digit is reset
to 0 and the digit to the left is increased by 1.
Hexadecimal numbers are often prefixed with either 0x to avoid ambiguity.
Input Data
First line will be D, the quantity of Decimal testcases.
D lines will then follow, each containing a single integer in Base-10
which you will be expected to convert into Base-16.
The next line will then be H, the quantity of Hexadecimal testcases.
H lines will then follow, each containing a single integer in Base-16
which you will be expected to convert into Base-10.
Answer
Should consist of D space-separated values followed by H space-separated
values, corresponding to the converted testcases.
Please write all hexadecimal values as lowercase letters where applicable.
Example
input data:
3
10
100
1000
3
0x10
0xabc
0xdeadbeef
answer:
a 64 3e8 16 2748 3735928559