F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Expressions

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/65535 K (Java/Others)
Total Submission(s): 262    Accepted Submission(s): 21


Problem Description
Have you taken the course named Data Structure? Did you pass it? If you do, you should know that a mathematical expression can be expressed as a tree and why. In this problem, you are given some expressions, and you are supposed to draw the tree.

The expressions are composed of these letters:
(1) 'a', 'b', ..., 'z' : means an operand;
(2) '+', '-', '*', '/' : dyadic operator, means plus sign, subtraction sign, multiplication sign and division sign;
(3) '-' : monadic operator, means negative sign;
(4) '(', ')' : used in pairs to alter priority.
 

Input
Input consists of multiple expressions each on a line (not exceed 50 letters). You should proceed to the end of file.
 

Output
For each expression, You should draw a tree that can express it, following the styles indicated in the sample output.

Note that the '#' in the sample are supposed to tell you that there are spaces at the back of some lines, and you should ignore it in your output.


 

Sample Input
a+b+c (a-a)*b+(-c)
 

Sample Output
+ # + c# a b # + # * - # - b c# a a #
 

Author
MDZfirst@TJU
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 12:29:02, Gzip enabled