#K86497. Evaluate Mathematical Expression

    ID: 36877 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

You are given a string representing a mathematical expression containing integers and the operators (+, -, \times, \div) (where (\div) represents integer division). The expression may include spaces and parentheses. Note that the operators (\times) and (\div) have higher precedence than ( + ) and ( - ). Your task is to correctly compute and output the result of this expression under integer arithmetic. If the input is empty, null, or the expression is malformed (e.g., unmatched parentheses or improper operator sequences), output None.

inputFormat

Input is provided via standard input (stdin) as a single line string that represents the mathematical expression. The expression can include digits, spaces, the operators +, -, *, /, and parentheses.

outputFormat

Output the evaluated integer result to standard output (stdout) as a single line. If the expression is empty or invalid, print None.## sample

3 + 5 * 2
13

</p>