#P10473. Expression Evaluation
Expression Evaluation
Expression Evaluation
Given an arithmetic expression containing integers (which may be negative) and the operators \(+, -, \times, \div, \wedge\) as well as parentheses, evaluate the final value of the expression.
The expression may include nested parentheses and even redundant parentheses. The input is guaranteed to result in a value within the int range.
Note: The exponentiation operator \(^\) is right-associative and has higher precedence than multiplication and division. Multiplication and division have higher precedence than addition and subtraction.
inputFormat
The input consists of a single line containing a valid arithmetic expression. The expression contains non-negative integers (possibly with a leading '-' for negative numbers), the operators +, -, *, /, and ^, and may include parentheses.
outputFormat
Output a single integer representing the evaluated result of the expression.
sample
1+2*3
7