Hide

Problem H
Number Squistem

/problems/numbersquistem/file/statement/en/img-0001.jpeg
Ponyo

Ponyo, after becoming human, needed to learn math. She quickly realized that $0$ is the most boring looking number.

So she created the glyph “<]:=” which replaces $0$, in remembrance of her friends the squids.

Thus, $10$ is now $1$<]:=, and $99 + 1 = 1$<]:=<]:=.

As an exercise, please help Ponyo perform all the math in the expressions given. Please evaluate this expression in the standard order of operations (multiplication and division should take precedence over addition and subtraction, and in case of ties in precedence, the operations should be evaluated left to right). Note that given Ponyo’s preferences, in the input expression, all $0$’s have been replaced with “<]:=”. Thus, in your output, please replace all 0’s with “<]:=” as well.

Input

There are 2 lines of input. The first line of input is a single integer n ($1 \leq n \leq 14$), representing how many mathematical operations are in the expression.

The second line is a string representing a mathematical expression. This string consists of $n+1$ numbers, with each number being separated by one of four mathematical operations “*”, “/”, “+”, or “-”. Here "/" represents integer division (i.e. when integers are divided, the result is then truncated towards zero). It is guaranteed there will be spaces between numbers and mathematical operations.

Each of the $n+1$ numbers is guaranteed to be between $1$ and $100$. They consist of the characters “1” through “9”, with “0” being replaced by the symbol “<]:=”.

All calculations are guaranteed to fit within a $32$-bit integer. Calculations should follow the correct order of operations. There are no negative numbers in the input, but the output may be negative. It is also guaranteed that division by zero will not occur within the input.

Output

Output one line containing a single integer $x$, the result of the expression. In this number $x$, please replace all $0$’s with “<]:=”.

Sample Input 1 Sample Output 1
1
1<]:= * 1<]:=
1<]:=<]:=
Sample Input 2 Sample Output 2
4
3 + 2<]:= / 1<]:= * 5 - 1<]:=
3
Sample Input 3 Sample Output 3
2
4<]:=4 - 8<]:= * 8
-236

Please log in to submit a solution to this problem

Log in