#K59467. Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
Arithmetic Expression Evaluation
You are given a valid arithmetic expression S consisting of non-negative integers and the operators +
, -
, *
, and /
. The expression does not include any parentheses.
Your task is to evaluate the expression following the standard operator precedence: multiplication and division are evaluated before addition and subtraction. Note that division should be treated as integer division, meaning the result is truncated towards zero.
Examples:
3+2*2
evaluates to7
3/2
evaluates to1
3+5 / 2
evaluates to5
inputFormat
The input consists of a single line containing the arithmetic expression S. The expression may include spaces.
outputFormat
Output a single integer which is the result of evaluating the expression.
## sample3+2
5