TCONNUM - Simple Numbers Conversion

Every integer number n is represented in positional number system of base r by a sequence of digits 0 ≤ di < r, so the value is equal to:

n = d0  + r * d1 + r2 * d2 + r3 * d3 + ...

Your task is to convert a given number in r-base represantation into s-base representation, for example: decimal 231 into binary 11100111. Assume that r ≤ 36 and the digits are 0,1,2,3,4,5,6,7,8,9, A, B, C, D, E, F, G, H, I, J, K, L, M, N, O, P, Q, R, S, T, U, V, W, X, Y, Z.

Input

N [the number of series ≤ 1000]
n r s [n ≤ 101000, r,s ≤ 36]

Output

n [s-base representation of number n]

Text grouped in [ ] does not appear in the input and output file.

Example

Input:
3
231 10 2
ABC 15 10
XYZ 36 2

Output:
11100111
2427
1010101111111011

Test cases

There are five categories of the input data:

  • Test case 1: (1 pt), r = 2 and s = 10, or conversely, n≤ 109, N = 100,

  • Test case 2: (1 pt), 2 ≤ r,s ≤ 10, n≤109, N = 1000,

  • Test case 3: (1 pt), 2 ≤ r,s ≤ 36, n≤ 109, N = 1000,

  • Test case 4: (3 pts), 2 ≤ r,s ≤ 10, n≤ 101000, N = 1000,

  • Test case 5: (4 pts), 2 ≤ r,s ≤ 36, n≤ 101000, N = 1000.

 


Added by:mima
Date:2004-10-13
Time limit:1s-5s
Source limit:5000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:ASM32 BF C C++ 4.3.2 CPP C99 PAS-GPC PAS-FPC

hide comments
2018-07-09 19:43:24
what is meant by
1
(threshold:3)
2018-02-07 05:14:30
What is meant by
Result
2(threshold: 3)

Last edit: 2018-02-07 05:15:01
2017-11-08 09:19:44 Lionel Messi
I have written the Java code for this problem for about 3 hours, then realise that there's no Java choice in submit options T_T

Last edit: 2017-11-08 09:21:08
2015-10-20 06:25:20
What is meant by
Result
0 (threshold: 3)
2015-04-08 11:36:53 Saad
:D
2015-03-23 18:53:54 Tamal Chowdhury
I am confused about
n<= 10^1000 or n<=101000 which is right?
2015-02-16 03:58:34 ZaidRehman A.R. Qureshi
can i submit this code in java ?

Last edit: 2015-02-16 03:58:54
2014-12-08 05:26:32 Julian Leyh
Why is this only for such a small set of languages? I would like to submit a solution in Ada..
2014-12-08 05:26:32 Andika Tanuwijaya
can someone explain what the categories means?
will the code be AC if it only complete one of the categories?
2014-12-08 05:26:32 Micha³ Ma³afiejski
please visit our forum, and try to describe the problem in details...
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.