ONP - Transform the Expression
Transform the algebraic expression with brackets into RPN form (Reverse Polish Notation). Two-argument operators: +, -, *, /, ^ (priority from the lowest to the highest), brackets ( ). Operands: only letters: a, b ... z. Assume that there is only one RPN form (no expressions like a*b*c).
Input
t [the number of expressions <= 100] expression [length <= 400] [other expressions]
Text grouped in [ ] does not appear in the input file.
Output
The expressions in RPN form, one per line.
Example
Input: 3 (a+(b*c)) ((a+b)*(z+x)) ((a+t)*((b+(a+c))^(c+d))) Output: abc*+ ab+zx+* at+bac++cd+^*
hide comments
Piotr Findeisen:
2013-02-13 15:04:40
Need better test: my accepted solution works incorrectly for:
|
|
Giovanni Botta:
2013-01-09 18:19:12
A question about performance:
|
|
Krzysztof Boduch:
2012-09-10 03:00:48
Why there is no objC? |
|
Hossam El-Deen Goodname:
2012-08-18 16:29:35
@KenCheung
|
|
xufei:
2012-06-26 05:51:06
does "Two-argument operators: +, -, *, /, ^ (priority from the lowest to the highest)" mean that priority of "-" is higher than that of "+"? Last edit: 2012-06-26 05:51:30 |
|
:D:
2012-05-08 09:29:58
Try to run it on ideone.com |
|
Ashish Raj:
2012-05-04 07:15:17
hey...i am writing my code in java...it is working fine in my netbeans..but when i submit here..it is giving me NZEC runtime error..what to do?
|
|
H. Gilles:
2012-04-22 22:00:54
Klaus, that's probably because of the language you're using.
|
|
Swati Narang:
2012-01-30 08:00:56
@ Ravi Kumar: For submitting any solution on this site, you should have only one public class in your file(as per Java rules) and the name of this public class should be "Main"(for spoj) :) |
|
Ravi Kumar:
2012-01-24 12:57:01
Hi i am newbie here i am writing solution in java. my code working fine at my system but when i submit the solution is shows some compilation error. The error is the name of the class is PostFix and it is saying that Class PostFix is public and should be in a file named PostFix.java. Is there any naming convention to follow for the class? Any sugession please....
|
Added by: | mima |
Date: | 2004-05-01 |
Time limit: | 5s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: NODEJS PERL6 VB.NET |
Resource: | - |