The Base Sum
All submissions for this problem are available.
Shyam loves a girl called Neeta.Neeta is the favourite student of his teacher.So the teacher had given her a task to find The Base Sum of a given number.A Base Sum of a given number is obtained by the following steps:
The sum is then obtained is termed as The Base Sum of a given number.
But Neeta has some other works to do so she will not be able to complete the task.Shyam being his classmate realized this thing and want to help Neeta.
As shyam is not so intelligent he came to you for help.Help shyam to impress Neeta.
Your task is to find the Base sum of a given number.
- The first line of input contains an integer T denoting the number of test cases. The description of T test cases follows.
- The second line contains two integers.
- First is N the number you have to convert and second is B the base in which you have to convert the number N
For each test case find the Base Sum of the given number.
- 1 ≤ T ≤ 1200
- 1 < N ≤ 1000000000
- 1 < B ≤ 1000000000
Input: 3 8 2 90 4 589626778 8 Output: 0 3 4
|Time Limit:||1 sec|
|Source Limit:||50000 Bytes|
|Languages:||C, CPP14, JAVA, PYTH, PYTH 3.5, PYPY, CS2, PAS fpc, PAS gpc, RUBY, PHP, GO, NODEJS, HASK, SCALA, D, PERL, FORT, WSPC, ADA, CAML, ICK, BF, ASM, CLPS, PRLG, ICON, SCM qobi, PIKE, ST, NICE, LUA, BASH, NEM, LISP sbcl, LISP clisp, SCM guile, JS, ERL, TCL, PERL6, TEXT, SCM chicken, CLOJ, FS|
Fetching successful submissions
If you are still having problems, see a sample solution here.