#C2967. Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
Arithmetic Expression Evaluator
You are given a string that represents a valid arithmetic expression. The expression can contain non-negative integers, the operators +
, -
, *
, /
, and parentheses (
and )
. Your task is to evaluate the expression and output its integer result. The operators must follow the standard order of operations: parentheses first, then multiplication and division, and finally addition and subtraction. Note that the division operator performs integer division, i.e. \(\lfloor \frac{a}{b} \rfloor\).
For example, given the input 10+(2*3)
the correct output is 16
, and for the input (1+(4+5+2)-3)+(6+8)
the output should be 23
.
inputFormat
The input consists of a single line containing a valid arithmetic expression with no spaces. The expression includes digits (0-9), the operators +
, -
, *
, /
, and parentheses (
and )
.
outputFormat
Output a single integer which is the evaluated result of the arithmetic expression, using integer division where applicable.
## sample3+5
8
</p>