406813: GYM102565 B Broken Python

Memory Limit:512 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

B. Broken Pythontime limit per test1 secondmemory limit per test512 megabytesinputstandard inputoutputstandard output

Jimmy was messing around with the $$$eval()$$$ function in python (he's too lazy to use a calculator), and he noticed that for some inputs he's running into issues with the recursion stack and hard-coded memory limits.

While he's desperately searching Stack Overflow for a solution to his problem, give him a hand and evaluate some expressions for him.

Input

The input consists of one line with the length $$$s \leq 10^5$$$ with integers and symbols. There are no white-space characters.

The allowed symbols are +, -, *, /, ^{}, (, ). As a reminder, the order of the operations is PEMDAS: parenthesis ('(', ')'), exponents ('^{}'), multiplication ('*'), division ('/'), addition ('+'), subtraction ('-'). For operations with the same priority($$$+-$$$, $$$*/$$$) we evaluate left to right.

For every integer $$$x$$$ in the input, $$$-10^9 < x < 10^9$$$.

If there are any expressions of the form $$$a$$$^{}$$$b$$$ in the input, we guarantee $$$b$$$ is a positive integer and not an expression.

Moreover, it is guaranteed that all unary operators are surrounded by parantheses.

Output

You should output the result to the given mathematical expression. We guarantee that $$$-10^9 < result < 10^9$$$ and that $$$result$$$ is an integer, but the intermediate results are unbounded and could be rational numbers.

ExamplesInput
1+1-1
Output
1
Input
35^66*0/35
Output
0
Input
(1/2)*2
Output
1

加入题单

算法标签: