| Online MIPT programming contest | РУССКИЙ |
| <PREV Problem: | NEXT> |
< |
|---|
Time limit = 1 second(s)
You should disclose parentheses in simple arithmetic expression without it's simplifying. This expression may consists of variables (characters from 'a' to 'z' in lower case), add signs ('+'), open and close parentheses ( '(' and ')' ), and multiplying without sings. For example:(a+b)(c+d)e+f
You should know that
1) ab ≠ ba.
2) expand braces starting with the leftmost expression:
(a+b)(c+d) = ac + ad + bc + bd,but
(a+b)(c+d) ≠ ac + bc + ad + bd.
Input: One line with Expression. The expression has less then 200 characters.
Output: You should open parentheses and output the result. If there is an error in the input expression then output "#ERROR".
Input#1(a+b+c)(a+b+f) |
Output#1aa+ab+af+ba+bb+bf+ca+cb+cf |
Input#2(a+c)ab |
Output#2aab+cab |
Input#3() |
Output#3 |
Input#4(+a) |
Output#4#ERROR |
Input#5((a) |
Output#5#ERROR |
Author:
Semi-final of Ukraine student olympiad, Khmelnitsky, march 2003.
24 april 2003
© acm.mipt DevGroup The page was generated in 340ms |