#C4458. Evaluate Infix Expression

    ID: 47998 Type: Default 1000ms 256MiB

Evaluate Infix Expression

Evaluate Infix Expression

This problem requires you to evaluate a mathematical expression written in infix notation. The expression contains non-negative integers, parentheses, and the operators +, -, *, and /. Operator precedence is defined as follows:

  • Multiplication and division have higher precedence than addition and subtraction.
  • Operations with the same precedence are performed from left to right.

Note that division is performed as integer division, which means the result is truncated towards zero. For example, the expression

\(\frac{100*(2+12)}{14}\) should evaluate to 100.

Your task is to implement an expression evaluator that computes the correct result given a valid expression string.

inputFormat

The input is a single line containing a valid infix mathematical expression.

The expression consists of digits (0-9), operators (+, -, *, /) and parentheses '(' and ')', with no spaces.

outputFormat

Output a single integer which is the result of evaluating the given expression.

## sample
3+5
8