P1981 [NOIP 2013 Junior] Expression Evaluation

Background

NOIP 2013 Junior T2.

Description

Given an arithmetic expression that contains only addition and multiplication, compute the value of the expression.

Input Format

One line: the expression to evaluate. The expression contains only digits, the addition operator `+`, and the multiplication operator `*`, with no parentheses. Every number that appears is an integer from $0$ to $2^{31}-1$. The input guarantees that this line contains only these $12$ characters: `0123456789+*`.

Output Format

Output a single integer: the value of the expression. Note: If the answer has more than $4$ digits, output only the last $4$ digits, and do not output leading $0$s.

Explanation/Hint

For $30\%$ of the testdata, the total number of addition and multiplication operators in the expression is between $0$ and $100$ inclusive. For $80\%$ of the testdata, the total number of addition and multiplication operators in the expression is between $0$ and $1000$ inclusive. For $100\%$ of the testdata, the total number of addition and multiplication operators in the expression is between $0$ and $100000$ inclusive. Translated by ChatGPT 5