#C12480. Evaluate Arithmetic Expression

    ID: 41912 Type: Default 1000ms 256MiB

Evaluate Arithmetic Expression

Evaluate Arithmetic Expression

Given an arithmetic expression as a string, your task is to evaluate it using integer arithmetic. The expression contains non-negative integers, the operators +, -, *, and /, and may include parentheses. Operator precedence follows the standard rules, where multiplication and division are evaluated before addition and subtraction. Division is performed as integer division. If a division by zero occurs at any point during the evaluation, output "Error". The expression may contain extra spaces. For example, the expression 3 + 5 / 2 * 3 - 6 evaluates to 3.

inputFormat

A single line from standard input that contains a valid arithmetic expression.

outputFormat

Output to standard output the evaluated result as an integer, or "Error" if a division by zero occurs.## sample

3 + 5 / 2 * 3 - 6
3