题目描述
<p> 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(<i>p</i> <i>e<sub>1</sub></i> <i>e<sub>2</sub></i>)where <i>p</i> is a real number between 0 and 1 (inclusive) and <i>e<sub>1</sub></i> and <i>e<sub>2</sub></i> are Smeech expressions. The value represented by a Smeech expression is as follows: </p> <ul> <li> An integer represents itself </li> <li> With probability <i>p</i>,(<i>p</i> <i>e<sub>1</sub></i> <i>e<sub>2</sub></i>)represents <i>x+y</i> where <i>x</i> is the value of <i>e<sub>1</sub></i> and <i>y</i> is the value of <i>e<sub>2</sub></i>; otherwise it represents <i>x-y</i>. </li> </ul> <p> Given a Smeech expression, what is its expected value? </p> <p> Input consists of several Smeech expressions, one per line, followed by a line containing (). For each expression, output its expected value to two decimal places. </p>
输入格式
<p> Please Input Input Here </p>
输出格式
<p> Please Input Output Here </p>
样例
样例输入 1
7
(.5 3 9)
()
样例输出 1
7.00
3.00
提交代码
请先登录后提交
🤖 AI 解题助手
DeepSeek
就绪