#C10156. Mathematical Expression Evaluator

    ID: 39330 Type: Default 1000ms 256MiB

Mathematical Expression Evaluator

Mathematical Expression Evaluator

You are given a mathematical expression E as a string. The expression contains non-negative numbers (which may be integers or decimals), the operators +, -, *, / and parentheses ( and ). Your task is to evaluate the expression following the standard operator precedence rules and output the result rounded to two decimal places. In the case of a division by zero or any invalid computation, output None.

For example, an expression may be interpreted as $$E = a + b \times c - \frac{d}{e}$$ Evaluate it accordingly. Note that even if the answer is an integer, it should be printed with two decimal places (e.g. 5 should be printed as 5.00).

Input: A single line containing the mathematical expression.

Output: A single line on stdout containing the evaluated result rounded to two decimals (or None in case of a division by zero error).

inputFormat

A single line string representing a valid mathematical expression. The expression may include numbers, operators (+, -, *, /) and parentheses. There are no guarantees of extra whitespace.

outputFormat

Print to stdout the result of the expression evaluation rounded to two decimal places. If the expression attempts to divide by zero or is invalid, output "None".## sample

3 + 2
5.00

</p>