#K36797. Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
Evaluate Arithmetic Expression
You are given a string representing a mathematical expression, which consists of non-negative integers, the operators +
, -
, *
, /
, and parentheses ( )
.
The expression should be evaluated using the standard operator precedence rules and integer division (truncate toward zero). It is guaranteed that the expression is valid.
For example, the expression \(2+3*4\) evaluates to \(14\), and \(100*(2+12)/14\) evaluates to \(100\).
inputFormat
The input consists of a single line containing a valid arithmetic expression. The expression includes integers, the operators +, -, *, /, and may have nested parentheses. There are no spaces in the input.
outputFormat
Output a single integer, which is the result of evaluating the expression according to standard arithmetic rules.## sample
2+3
5
</p>