Приглашаем всех школьников принять участие в Заочной олимпиаде ФУПМ по программированию

<PREV Problem:
NEXT>
Solved by 556 users: ...
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 
 < 

Arithmetica 1.0

Time limit = 5 second(s)

Memory limit = 33000 Kb

You are the main programmer of Walfram Research Corp.

You should wrigh program Arithmetica v1.0, that works as calculator.

Arithmetica v1.0 calculates arithmetic expressions over integer numbers (not very long) constructed from brackets ( ) and binary operators + — *. Unary minus is also allowed.

Operators have equal priority and should be calculated from left to right. It means that 1+1*2=4.

The number of symbols in input expression less than 1000.

Input One line with correct arithmetic expression less than 1000 symbols. Consider all numbers emerging during calculation of the expression small in absolute value, less than 230. Arithmetics of long integers will be realised in future versions.

Output One integer number — result of calculations.

Input#1
1+1
Output#1
2
Input#2
-1+(2*3)
Output#2
5
Input#3
1+(1+(1+(1-1)*2)*2)*2
Output#3
14
Input#4
(((-1)))
Output#4
-1
Input#5
-1000*1000
Output#5
-1000000

Author:
Voroztsov Artem
26 March 2003

<PREV | Problem set | Search related messages | NEXT>


© acm.mipt DevGroup
The page was generated in 220ms

SW soft NIX
ID = 54.90.138.104