No.2087 Base Conversion
Note
After the contest ended, the input format was changed to use KaTeX. The content of the problem itself has not changed.
Problem Statement
You are given as input an integer $N$ (written in decimal) between $2$ and $10$, inclusive, and a non-negative integer $M$ (written in decimal).
Express $M$ in base $N$.
This is a typical problem that also appears in high school textbooks, but let's review it, considering it an important first step toward understanding base $p$.
Input
The input is given from standard input in the following format:
$N$ $M$
Constraints
The inputs $N,M$ satisfy the following constraints:
- $N$ is a non-negative integer between $2$ and $10$, inclusive
- $M$ is a non-negative integer at most $10^9$
Output
Output $M$ expressed in base $N$ on $1$ line.
Print a newline at the end.
Sample
Sample 1
Input
2 2
Output
10
Decimal $2$ is $10$ in binary.
Sample 2
Input
3 2
Output
2
Decimal $2$ is $2$ in ternary. As this shows, the representation may stay the same.
Sample 3
Input
3 9
Output
100
Decimal $9$ is $100$ in ternary. What a nice round number.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。