Skip to main content
Tuesday (24.11.2026) at 20:00: ALGOR Contest: Round #4 (Special Challenge) starts!

~/algor $ cat problems/while-k-lik-sanoq-sistemasi

Conversion to base k

Medium 1000 ms 64 MB 48%
Share

Two integers $n$ and $k$ are given. Find the notation of $n$ in the base-$k$ numeral system (for example, $10 = 1 * 3^{2} + 0 * 3^{1} + 1 * 3^{0} = 101_{3}$).

Repeated division of the number by the base k and writing down the remainders

Input

One line with two integers: $n$ and $k$.

Output

The base-$k$ notation of $n$ — no spaces between digits and no extra leading zeros; if $n = 0$, print 0.

Note

$0 \le n \le 10^{9}$
$2 \le k \le 9$

Examples

Input #1
10 3
Output #1
101
Input #2
255 2
Output #2
11111111

Sign in to submit a solution

Signing up is free and takes a minute.