#P2084. 进制转换

    ID: 1024 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 1 上传者: 标签>模拟字符串线性结构洛谷原创

进制转换

Description

Today, Xiao Ming learned base conversion. For example, for (10101)2(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 NN in base MM into its decimal representation as an expression.

Note: When a coefficient is 00, that term should be omitted.

Input Format

Two integers, MM and NN, separated by a space.

Output Format

One line: the decimal representation as an expression.

2 10101
1*2^4+1*2^2+1*2^0

Hint

For 100%100\% of the testdata, 1<M<101 < M < 10, the number of digits of NN does not exceed 10001000, and each digit is an integer in [0,M1][0, M-1].

Translated by ChatGPT 5