Smeech
Very easy
Execution time limit is 1 second
Runtime memory usage limit is 64 megabytes
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 (p e_1 e_2) where p is a real number between 0 and 1 (inclusive) and e_1 and e_2 are Smeech expressions. The value represented by a Smeech expression is as follows:
An integer represents itself
With probability p, (p e_1 e_2) represents x + y where x is the value of e_1 and y is the value of e_2; otherwise it represents x - y.
Given a Smeech expression, what is its expected value?
Input
Consists of several Smeech expressions, one per line, followed by a line containing ( ).
Output
For each expression, output its expected value to two decimal places.
Examples
Input #1
Answer #1
Submissions 79
Acceptance rate 38%