eolymp
bolt
Try our new interface for solving problems
Problems

Smeech

Smeech

\includegraphics{https://static.e-olymp.com/content/84/84b033ad36d4b084a3c8ca702baf914ff95e2f8c.jpg} Professor Octastichs has invented a new programming language, Smeech. An expression in Smeech may be a positive or negative integer, or may be of the form \textbf{(p e_1 e_2)} where \textbf{p }is a real number between \textbf{0} and \textbf{1} (inclusive) and \textbf{e_1} and \textbf{e_2} are Smeech expressions. The value represented by a Smeech expression is as follows: \begin{itemize} \item An integer represents itself \item With probability \textbf{p}, \textbf{(p e_1 e_2) }represents \textbf{x + y }where \textbf{x }is the value of \textbf{e_1} and \textbf{y }is the value of \textbf{e_2}; otherwise it represents \textbf{x - y}. \end{itemize} Given a Smeech expression, what is its expected value? \InputFile Consists of several Smeech expressions, one per line, followed by a line containing \textbf{( )}. \OutputFile For each expression, output its expected value to two decimal places.
Time limit 1 second
Memory limit 64 MiB
Input example #1
7
(.5 3 9)
()
Output example #1
7.00
3.00