DCP-22: Number Base Back to All Problems

Easy Math > Basic Math


Do you know why base 10 number system is so easy to understand to us? The only reason base-10 math seems "natural" and the other bases don't is that you've been doing base-10 since you were a child. And (nearly) every civilization has used base-10 math probably for the simple reason that we have ten fingers. If instead we lived in a cartoon world, where we would have only four fingers on each hand (count them next time you're watching TV or reading the comics), then the "natural" base system would likely have been base-eight, or "octal". Other than base 10, binary, octal and hexadecimal are popularly known number bases that we use. But number can be in lot more bases than these few. For example, we can consider base 4 or base 22. In this problem you will be given a decimal number and you have to convert that number to a destination base. Input: ------ The first line of the input contains an integer, **T**, representing the number of test cases **(1 ≤ T ≤ 100)**. For each test case, two numbers separated by comma, the first one contains a number **N (0 ≤ N ≤ 2^31-1)**, representing the decimal number and the second one contains a number **B (2 ≤ B ≤ 35)**, representing the destination number system base. Output: ------- For each test case the output should contain a single line with the number in the destination base number system. For base greater than 10, letters A to Z should be used to represent the digit in that base where A means 10, B means 11, C means 12 and so on up to Z. Sample Input ------------ 4 10,2 100,5 999,9 135534,22 Sample Output ------------- 1010 400 1330 CG0E


Problem Setter:

MD. Jalal Uddin

Please login to submit solution to this problem.

Problem Limits

Language Time Limit (seconds)
C/C++ 1.00
Java 2.00
C# 2.00
PHP 2.00

Problem Stats

45/151

Solve/Submission

Ranking

# User Language Timing
01 tariqiitju Cpp 0.00s
02 absa1am Cpp 0.00s
03 Logic_Hunter Cpp 0.00s
04 SKL12 Cpp 0.00s
05 Indro_BU Cpp 0.00s
06 sazal_dev Cpp 0.00s
07 ash12 Cpp 0.00s
08 Mr_KAJOL_JUST Cpp 0.00s
09 Masum_ice Cpp 0.00s
10 deder Cpp 0.00s
11 onucsecu Cpp 0.00s
12 SakibAlamin Cpp 0.00s
13 Ansarul_14 Cpp 0.00s
14 Rajan_sust Cpp 0.00s
15 murad_al_wajed Cpp 0.00s
16 seyedssz Cpp 0.00s
17 Nazmul_7 Cpp 0.01s
18 Ashish972 Cpp 0.01s
19 nazmul_bzs Cpp 0.01s
20 emrul Cpp 0.01s
21 Rahat_BU Cpp 0.01s
22 mhsjaber CSharp 0.03s
23 tanmoycsit CSharp 0.05s
24 Bishal_G CSharp 0.05s
25 Dinar Cpp 0.07s
26 mahrahat Cpp 0.08s
27 mahbub07 Cpp 0.30s
28 codehead Cpp 0.31s
29 froghramar Cpp 0.39s
30 moshiur_cse15 Cpp 0.40s
31 abd_iubat Cpp 0.40s
32 sharifulalam Cpp 0.40s
33 myhobby Cpp 0.43s
34 njrafi Cpp 0.46s
35 Sabyasachi Cpp 0.48s
36 swapnil Cpp 0.49s
37 showmic Cpp 0.51s
38 duronto20 Cpp 0.58s
39 anowar1112 Cpp 0.61s
40 haasib Java 1.49s
Feedback

Your feedback is our precious!



Or call +88 02 9853138 for support