luogu#P2084. 进制转换

    ID: 6132 Type: RemoteJudge 1000ms 125MiB Tried: 12 Accepted: 9 Difficulty: 1 Uploaded By: Tags>字符串模拟线性结构洛谷原创

进制转换

Problem 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