P2084 Base Conversion

Description

Today, Xiao Ming learned base conversion. For example, for $(10101)_2$, its decimal representation as an expression is: $$1\times 2^4+0\times 2^3+1\times 2^2+0\times 2^1+1\times 2^0$$ Please write a program that converts a number $N$ in base $M$ into its decimal representation as an expression. Note: When a coefficient is $0$, that term should be omitted.

Input Format

Two integers, $M$ and $N$, separated by a space.

Output Format

One line: the decimal representation as an expression.

Explanation/Hint

For $100\%$ of the testdata, $1 < M < 10$, the number of digits of $N$ does not exceed $1000$, and each digit is an integer in $[0, M-1]$. Translated by ChatGPT 5