#K53842. Evaluate Mathematical Expression
Evaluate Mathematical Expression
Evaluate Mathematical Expression
You are given a mathematical expression as a string. The expression contains non-negative integers, operators +
, -
, *
, /
, ^
(exponentiation) and parentheses. The operator ^
stands for exponentiation and should be treated with the highest precedence. Use integer division for the division operator. Your task is to evaluate the expression and output its integer result.
Note: The expression is guaranteed to be valid. Operands may have multiple digits and spaces may appear arbitrarily in the expression.
inputFormat
The input consists of a single line that contains the arithmetic expression. For example:
3 + 2 * (2 - 1)
outputFormat
Output a single integer which is the result of evaluating the expression. For instance, the above input should produce:
5## sample
3
3
</p>