#C13189. Evaluate Mathematical Expression

    ID: 42699 Type: Default 1000ms 256MiB

Evaluate Mathematical Expression

Evaluate Mathematical Expression

Given a string representing a mathematical expression, compute its value. The expression supports addition, subtraction, multiplication, division and parenthetical grouping. Operations follow the standard precedence rules; expressions inside parentheses are evaluated first. If the expression is invalid or if a division by zero occurs, print an appropriate error message.

Note: The expression must contain only digits, the operators +, -, *, /, decimal points, parentheses and spaces.

inputFormat

A single line from standard input (stdin) containing a valid mathematical expression.

outputFormat

Output a single line to standard output (stdout) with the computed result. If the result is an integer, output it without a decimal point.## sample

2 + 3
5