#C6851. Evaluate Mathematical Expression

    ID: 50657 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

Given a mathematical expression as a string expression consisting of non-negative integers and the operators \(+, -, \times, \div\) (with \(\div\) representing integer division), compute and return the result of the expression. The expression may include extra whitespace, and the usual operator precedence applies (i.e. \(\times\) and \(\div\) have higher precedence than \(+\) and \(-\)).

For example, for the input 3+5 / 2, the evaluation is performed as \(3 + \lfloor5/2\rfloor = 3 + 2 = 5\). Similarly, the expression 12 * 3 - 4 / 2 evaluates to \(12 \times 3 - \lfloor4/2\rfloor = 36 - 2 = 34\).

Your task is to implement a program that reads such an expression from the standard input and prints the evaluated integer result to the standard output.

inputFormat

A single line containing a mathematical expression. The expression contains non-negative integers, operators (+, -, *, /) and may include whitespace.

outputFormat

Output a single integer which is the result of evaluating the given expression using standard operator precedence. Division is performed as integer division (i.e., the quotient is truncated).## sample

3+5
8