| # | Problem | Pass Rate (passed user / total user) |
|---|---|---|
| 10961 | Prefix expression |
|
| 10954 | Prefix to truth table |
|
Description
Give a prefix expression, which only has 2 operators, ‘+’ and ‘-’,and positive integers. Print the result.
Input
The input contains a sequences of prefix expression. It contains operators, ‘+’ and ‘-’,and positive integers separated by a space. Expression is ended by 0. (0 is not the element.)
Output
The output is the result of the expression. (Without a newline symbol)
Sample Input Download
Sample Output Download
Tags
Discuss
Description
Give a prefix Boolean expression, which only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’, print its truth table.
For example, if input is "|&AC|AB", then result will be
A B C D output
0 0 0 0 0
0 0 0 1 0
0 0 1 0 0
0 0 1 1 0
0 1 0 0 1
0 1 0 1 1
0 1 1 0 1
0 1 1 1 1
1 0 0 0 1
1 0 0 1 1
1 0 1 0 1
1 0 1 1 1
1 1 0 0 1
1 1 0 1 1
1 1 1 0 1
1 1 1 1 1
Input
The input contains a sequences of prefix expression. It only has at most 4 variables ‘A’, ‘B’, ‘C’, and ‘D’, and 2 operators, AND ‘&’ and OR ‘|’. The length of prefix expression is shorter than 30.
Output
It has 5 variables 'A', 'B', 'C', 'D', and output, each variable is separated by a space.