#K79657. Mathematical Expression Validator

    ID: 35357 Type: Default 1000ms 256MiB

Mathematical Expression Validator

Mathematical Expression Validator

You are given a string representing a mathematical expression. Your task is to determine whether the expression is valid. An expression is considered valid if it satisfies all of the following conditions:

  • Numbers must be a positive integer or a decimal. In LaTeX: $$n \in \mathbb{Z}^+ \quad \text{or} \quad n = a.b$$ (e.g., 3, 1.0, 0.5).
  • The only valid operators are $$+, -, \times, \div$$. They must appear between two valid numbers (or valid sub-expressions).
  • Parentheses, ( and ), must be correctly paired and properly nested.
  • Spaces should be ignored.

Output Valid expression if the expression is valid, otherwise output Invalid expression.

inputFormat

The input is a single line read from standard input (stdin) that contains a mathematical expression. The expression may include digits, decimal points, the operators +, -, *, /, parentheses ( and ), and spaces.

outputFormat

Output a single line to standard output (stdout) containing either Valid expression or Invalid expression depending on whether the expression satisfies the rules.

## sample
3 + 5
Valid expression