#C14674. Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
You are given an arithmetic expression as a string. The expression consists of non-negative integers, parentheses, and the operators +, *, and /. Your task is to evaluate the expression according to the standard operator precedence rules (multiplication and division have higher precedence than addition). Note that division is performed as integer division, i.e., for any two integers \(a\) and \(b\) (with \(b \neq 0\)), \[ a / b = \lfloor a/b \rfloor \] Spaces in the input should be ignored.
Examples:
- Input:
2+3
→ Output:5
- Input:
2*3
→ Output:6
- Input:
(2+3)*4
→ Output:20
inputFormat
The input consists of a single line containing an arithmetic expression. The expression may include spaces, non-negative integers, parentheses, and the operators +
, *
, and /
.
outputFormat
Output a single integer representing the evaluated result of the expression.
## sample2+3
5