#B2143. Recursive Base Conversion

    ID: 11225 Type: Default 1000ms 256MiB

Recursive Base Conversion

Recursive Base Conversion

Given a decimal integer \(X\) and a base \(M\), use a recursive algorithm to convert \(X\) from decimal to a numeral system with base \(M\). The constraints are given as follows:

  • \(1 \le X \le 10^9\)
  • \(2 \le M \le 16\)

The conversion should produce digits 0-9 and uppercase letters A-F for digit values 10 to 15.

inputFormat

The input consists of two numbers separated by space:

  • X: a decimal integer.
  • M: an integer representing the target base.

You may assume that the input meets the given constraints.

outputFormat

Output the representation of \(X\) in base \(M\) using the recursive algorithm described. There should be no extra spaces or characters in the output.

sample

10 2
1010