Submit  All submissions  Best solutions  Back to list 
POS_NOTA  Positional notations 
Wersja polska  English version 
Your task is to change number n from decimal to in basep positional notation.
Input
The first line of the standard input contains one integer t (t<10001) which is the number of test cases.
In each of the next t lines there are two numbers: n<22*10^{8} and p<17 (n  number in decimal, p  base in which you should print number n).
Output
For each test, print number n in basep positional notation.
Example
Input:
7
4 5
4 3
4 2
4 4
12 16
123 10
123 13
Output:
4
11
100
10
c
123
96
Added by:  Piotr Ką kol 
Date:  20100110 
Time limit:  2.854s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: SCM qobi 
Resource:  Positional notation 
hide comments
20120221 19:53:48 Mitch Schwartz
n>0 

20110104 16:14:07 Piotr KÄ…kol
n limit added. Thanks. 

20110104 13:50:30 Hallvard Norheim Bø
What is the limit on n? 

20100801 16:15:10 Piotr KÄ…kol
They're not too slow. They just aren't available (gawk,bc,nawk,dc,sed) but I asked to add them. Edit: You can add other commands is this topic on SPOJ forum which aren't available. Last edit: 20100801 16:16:00 

20100801 14:56:58 HWK
I wrote some solutions with BASH. Either they're too slow or they don't work as against at home. Are awk or sed installed in the testenvironment? 

20100409 22:35:54 Piotr KÄ…kol
Time limit has been changed to 10sec. ;) Last edit: 20100425 09:20:09 

20100120 23:16:35 Piotr KÄ…kol
Thanks! I have changed tests after making this task and forgot to change the examples. 

20100120 20:04:44 .:: Pratik ::.
Output in given sample is not captial C, must be lowercase C. 

20100120 09:10:45 .:: Pratik ::.
Is n always an integer? 