#C9728. Expression Evaluation Challenge

    ID: 53853 Type: Default 1000ms 256MiB

Expression Evaluation Challenge

Expression Evaluation Challenge

You are given a string representing a mathematical expression. The expression contains integer operands and the operators +, -, *, and / separated by spaces. The expression might also contain parentheses to enforce precedence. Note that the division operator performs integer division (i.e. the result is the quotient of the division).

Your task is to evaluate the expression correctly following the operator precedence and output the computed integer result.

Examples:

  • Input: 3 + 5 → Output: 8
  • Input: 10 + 2 * 6 → Output: 22
  • Input: 100 * ( 2 + 12 ) / 14 → Output: 100

All tokens in the input string (numbers, operators, and parentheses) are separated by spaces.

inputFormat

The input consists of a single line containing the mathematical expression as a space-separated string.

outputFormat

Print a single integer representing the evaluated result of the expression.

## sample
3 + 5
8

</p>