Pro.ID22240 TitleThe Earth is Flat Title链接http://10.20.2.8/oj/exercise/problem?problem_id=22240 AC0 Submit0 Ratio- 时间&空间限制描述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$ Sample Output w Source 样例输入w$ 样例输出w 作者 |