21353_Smeec

2022-5-16 18:19| 发布者: Hocassian| 查看: 48| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-89505184864600-Problem List-采集的数据-后羿采集器.html

Pro.ID

21353

Title

Smeech

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21353

AC

9

Submit

81

Ratio

11.11%

时间&空间限制

  • Time Limit: 600/200 MS (Java/Others)     Memory Limit: 65536/32768 K (Java/Others)
  • 描述

    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  e1  e2 ) where p is a real number between 0 and 1 (inclusive) and e1 and e2 are Smeech expressions. The value represented by a Smeech expression is as follows:

    • An integer represents itself

    • With probability p, ( p  e1  e2 ) represents x+y where x is the value of e1 and y is the value of e2; 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 ().

    输出

    Description

    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  e1  e2 ) where p is a real number between 0 and 1 (inclusive) and e1 and e2 are Smeech expressions. The value represented by a Smeech expression is as follows:

    • An integer represents itself

    • With probability p, ( p  e1  e2 ) represents x+y where x is the value of e1 and y is the value of e2; otherwise it represents x-y.

    Given a Smeech expression, what is its expected value?

    Input

    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.

    Sample Input

    7
    (.5 3 9)
    ()

    Sample Output

    7.00
    3.00

    Source

    样例输入

    7
    (.5 3 9)
    ()

    样例输出

    7.00
    3.00

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部