22240_TheEarthisFla

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

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

Pro.ID

22240

Title

The Earth is Flat

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 1000/500 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Consider the following language:

    The left column of the table below includes sample expressions of this language. Now the flattening of an expression is defined as follows: A single letter is flattened to itself. An expression of the form ( e1  e2 ··· et n ) is flattened by concatenating n copies of the concatenation of the flattening of ei. In other words, if f(e) is the flattening of e, and + symbolizes concatenation, then f((e1  e2 ···  et  n)) is:

    The following tables show some sample expressions and the result of flattening each.

    Write a program to flatten a given expression.

    输入

    Your program will be tested on one or more test cases. Each test case is made of one correctly formed expression written on a separate line. A '$' character identifies the end of line. The last line of the input, which is not part of the test cases, contains a '$' by itself (possibly with leading and/or trailing white spaces). Every expression in the input is grammatically correct according to the grammar specified above. Note that an expression may contain leading, trailing, and/or embedded spaces. Such spaces should be ignored. Letters and numbers are separated from each other by at least one space character.

    输出

    Description

    Consider the following language:

    The left column of the table below includes sample expressions of this language. Now the flattening of an expression is defined as follows: A single letter is flattened to itself. An expression of the form ( e1  e2 ··· et n ) is flattened by concatenating n copies of the concatenation of the flattening of ei. In other words, if f(e) is the flattening of e, and + symbolizes concatenation, then f((e1  e2 ···  et  n)) is:

    The following tables show some sample expressions and the result of flattening each.

    Write a program to flatten a given expression.

    Input

    Your program will be tested on one or more test cases. Each test case is made of one correctly formed expression written on a separate line. A '$' character identifies the end of line. The last line of the input, which is not part of the test cases, contains a '$' by itself (possibly with leading and/or trailing white spaces). Every expression in the input is grammatically correct according to the grammar specified above. Note that an expression may contain leading, trailing, and/or embedded spaces. Such spaces should be ignored. Letters and numbers are separated from each other by at least one space character.

    Output

    For each test case expression, write its flattening on a separate line. There should be no spaces (other than newlines) in the output.

    Sample Input

    w$
    (c 4)$
    (a (b c 2) 3)$
    $

    Sample Output

    w
    cccc
    abcbcabcbcabcbc

    Source

    样例输入

    w$
    (c 4)$
    (a (b c 2) 3)$
    $

    样例输出

    w
    cccc
    abcbcabcbcabcbc

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部