#K45117. Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
You are given an arithmetic expression containing non-negative integers and the operators + and *. In this expression, the multiplication operator has higher precedence than the addition operator. That is, all multiplicative operations should be performed before any additive operations.
Your task is to evaluate the expression and output the computed integer result.
Note: The expression is provided as a single line with tokens separated by spaces. For example, the expression 3 + 5 * 2
should be evaluated as 3 + (5 * 2), resulting in 13.
The mathematical precedence can be formally expressed as: \[ \text{Result} = \text{sum}_{i=1}^{k} \, \prod_{j} a_{ij} \] where multiplication (\(\times\)) is performed prior to addition.
inputFormat
The input consists of a single line containing the arithmetic expression. The expression has non-negative integers and the operators '+' and '*' separated by single spaces.
outputFormat
Output a single line with one integer, denoting the result of evaluating the given expression.
## sample3 + 5
8