#C12205. Evaluate Mathematical Expressions

    ID: 41607 Type: Default 1000ms 256MiB

Evaluate Mathematical Expressions

Evaluate Mathematical Expressions

You are given a list of mathematical expressions to evaluate. The first line of the input contains an integer \(n\), which represents the number of expressions. Each of the following \(n\) lines contains a single expression. The expressions can include the basic arithmetic operators: addition (+), subtraction (−), multiplication (\(\times\)) and division (/).

For each expression, you must compute its value. If the evaluation is successful, output the result. Note that for division, the result should be presented as a floating-point number (even if it is equivalent to an integer). If any expression cannot be evaluated due to an error, such as division by zero or a syntax error, output None for that expression.

Use standard operator precedence in your calculations. The expressions are guaranteed to use valid spacing, but may be invalid in content.

inputFormat

The input is read from stdin. The first line contains an integer n — the number of expressions. The next n lines each contain one mathematical expression.

outputFormat

For each expression, output its evaluation result on a new line. If an expression results in an error (for example, division by zero or a malformed expression), output 'None' (without quotes).## sample

5
3 + 5
10 * 2
6 / 3
8 - 4
12 / 4
8

20 2.0 4 3.0

</p>