TCNUMFL - Simple Numbers with Fractions Conversion

no tags 

Every integer number n is represented in positional number system of base r by a sequence of digits 0 <= di < r, decimal point ',' and fractional part, so the value is equal to:

n = d0 + r * d1 + r2 * d2 + r3 * d3 + ... + r-1 * d-1 + r-2 * d-2 + r-3 * d-3 + ...

Your task is to convert a given number in r-base representation into s-base representation with l digits after decimal point (no rounding - use floor), for example: decimal 231, 5 into binary 11100111, 1 with one digit after decimal point. 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 l [n < 361000 + 1, r, s <= 36, l <= 1000 ]

Output

n [s-base representation of number n]

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

Example

Input:
10
500,1 6 31 3
3866,DJ 22 27 1
EH75,L3 24 4 3
A73C,10B 13 27 2
6C6J,E483 22 6 2
JA,L 30 5 4
6,5A 20 31 2
1,C5 14 7 1
HD,6K 26 9 2
1001,011 2 10 3

Output:
5P,555
1M8H,H
301223231,320
14MB,25
1255211,35
4310,3222
6,8G
1,6
555,23
9,375

hide comments
(Tjandra Satria Gunawan)(曾毅昆): 2015-02-08 15:47:10

That strange, someone disqualified my old AC (2 years ago) (I don't know who because after rejudge it appear as AC but didn't appear on rank table), just resubmitted my old code and then AC again.

Vamsi Krishna Avula: 2015-02-06 10:16:33

can this problem be solved without using bigint?

Piotr KÄ…kol: 2015-02-05 12:01:01

I've set time limit to 2.5s and made a rejudge. Some submissions may have incorrect time if they are on an old cloud ending. But seems ok.

numerix says: Thanks a lot, it's okay now.

Last edit: 2015-02-05 12:49:18
numerix: 2015-01-31 16:48:19

I will try once again:
On Pyramid the TL was 13 s (you can conclude that from the results in the submission list), my former AC Python solution had a runtime of 10 s.
Now TL is set to 0.1 s (yes, it has been increased from 0.00 s to 0.10 s ...) and all remaining AC submissions have a runtime of 0.00 s. I cannot believe that those runtimes are the result of a correct Cube rejudge. Perhaps one of the AC users can resubmit his code and confirm that. Moreover there has been no AC submission in the last 2 years.

--Francky--> New mail to admins. Thanks for your catch.

Last edit: 2015-01-31 17:33:15
Francky: 2014-11-23 18:05:42

@numerix : I agree it causes some troubles, EB asked admin about those changes, we didn't have yet any answers. I can only propose to feed this thread ; perhaps some ideas will raise.

numerix: 2014-11-23 18:05:42

@Mitch: I'm quite sure it happened within the last 24 hours. And there are other problems "switching" at the moment. DIV and DIV2 just "switched" within the last one or two hours.

Mitch Schwartz: 2014-11-23 18:05:42

@numerix: Do you know if this change was very recent, or if it was part of the changes that happened around Oct 6th?

Edit: Thanks for the reply. I will probably write another email to admins.

Edit 2: Francky sent an email before I could get around to it. (Thanks!)
--ans(Francky)--> I've sent too a cc of this mail to numerix.

Last edit: 2014-11-15 10:56:18
numerix: 2014-11-23 18:05:42

Another problem that has switched from Pyramid to Cube cluster. Time limit now is 0 s, that is ridiculous. Again my former AC Python submission has become invalid ("internal error" instead of AC). That is really frustrating!

Last edit: 2014-11-14 15:01:58
[Trichromatic] XilinX: 2014-11-23 18:05:42

Em. If your time shown on the status page is 26.XX seconds, your program actually has been killed before it terminates.


Added by:Piotr Piotrowski
Date:2004-11-08
Time limit:2.5s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All