#B3849. Decimal to Arbitrary Base Conversion

    ID: 11506 Type: Default 1000ms 256MiB

Decimal to Arbitrary Base Conversion

Decimal to Arbitrary Base Conversion

This problem involves converting a given non-negative decimal number to base R (with 2 ≤ R ≤ 36). In hexadecimal, for example, letters A-F are used to represent values 10-15. Here, the conversion is generalized so that letters A-Z can be used to represent values 10-35, enabling conversion to any base up to 36.

You are given two inputs on a single line: the decimal number and the base R. Your task is to output the representation of the decimal number in base R using digits 0-9 and uppercase letters A-Z where applicable.

Note: If the number is 0, the output should be 0.

inputFormat

The input consists of a single line containing two space-separated values:

  • An integer n representing a non-negative decimal number.
  • An integer R representing the target base (2 ≤ R ≤ 36).

outputFormat

Output the string representation of the number n in base R. Use digits 0-9 and uppercase letters A-Z for digits greater than 9.

sample

10 2
1010