~/algor $ cat problems/stack-postfiks-ifoda
Evaluating a postfix expression
Medium
1000 ms
128 MB
51%
A correct expression in postfix notation is given: in it an operation sign is written after its two operands, and a b - means $a - b$. For example, the expression $(3 + 4) * 2$ is written as 3 4 + 2 *. The operations are +, -, *. Find the value of the expression.
Input
One line with integers and operation signs separated by spaces.
Output
One integer — the value of the expression.
Note
The expression has at most $3 * 10^{5}$ numbers and operation signs in total
Each number is from $0$ to $100$
Every intermediate value and the answer are from $-10^{18}$ to $10^{18}$
Examples
Input #1
3 4 + 2 *
Output #1
14
Input #2
5 1 2 + 4 * + 3 -
Output #2
14