시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 0 0 0 0.000%

문제

Write a program that can evaluate expressions from the following roughly BNF (Backus Naur Form) grammar:

expr ::=  term | expr ‘+’ term | expr ‘-’ term
unary_op ::= ‘+’ term | ‘-’ term
term ::= ‘(’ expr ‘)’ | ‘(’ unary_op ‘)’ | literal
literal ::= [0-9]

There will be no whitespace within an expression. All expressions will consist solely of the characters (, ), +, -, and the digits 0 through 9. You may assume that all input is well-formed.

입력

The input will consist of one expression per line followed by a newline. There will be no blank lines in the file.

출력

For each expression, output its integer value, followed by a single newline.

예제 입력

1
(-2)+3
(1-(2+3))
(1-2+3)
(1-(+(2-3)))

예제 출력

1
1
-4
2
2

힌트