#C13563. Evaluate Mathematical Expression

    ID: 43115 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

You are given a string representing a mathematical expression. The expression may contain non-negative integers, operators +, -, *, /, and parentheses ( ). Your task is to evaluate this expression following the standard order of operations:

  • Parentheses first
  • Multiplication and division (from left to right)
  • Addition and subtraction (from left to right)

Note that division should be interpreted as integer division, i.e. the result is the quotient of the division, discarding any remainder.

You can assume that the given expression is always valid.

inputFormat

The input consists of a single line read from standard input (stdin) containing the expression string. The expression may include spaces.

For example:

(2+3)*4

outputFormat

Output a single integer to standard output (stdout), which is the result of evaluating the expression.

For example:

20
## sample
3 + 2
5