BASECVT - Base Conversion (Easy)
We want to make some base-conversion experiments. Here you can try basic methods.
The first line of input contains three integers T, the number of test cases, B1, the first base, B2, the second base. Follow 2×T lines. For each test case, on the first line your are given one integer k. On the second line you are given k integers : the digits of N in base B1. N = a0×B10 + ... + ai×B1i + ... + ak-1×B1k-1
For each test case, you have to print the number N in base B2. See sample for details.
Input: 1 10 100 5 5 4 3 2 1
Output: 3 <--- Don't forget the length of N in base B2 ;-) 45 23 1
For the lonely case, N = 5×100 + 4×101 + 3×102 + 2×103 + 1×104 = 12345. We have: N = 45×1000 + 23×1001 + 1×1002. You have to print 3, the number of digits, then the digits: 45, 23 and 1.
0 < T <= 200 1 < B1,B2 <= 10^9 1 < k <= 1000 0 <= ai < B1 , ak-1>0
If you find the constraints too easy, then you should try BASECONV. The basic solution should give AC in 1.56s with Python3. (Edit 2017-02-11 : 0.42s with new compiler) Have fun ;-)
It seems my basic solution is more basic than your basic solution. :p