Sphere Online Judge

SPOJ Problem Set (challenge)

2004. Analyse Simple Arithmetical Expressions

Problem code: EXPR2

You are to write a program to analyse some simple arithmetical expressions. The BNF form of the defination of the expression is below.

<expression>::=<num><oper><num>
<num>::=0|1|2|...|99
<oper>::=+|-|*

Tip: You may find this problem is like the problem GALAXY very much. To get round of the programming problems of using Brainf**k, Whitespace or Intercal, you must use C/C++/Pascal/Java to do the programming. Seems easy? Now there is an additional objective: there must not be any semicolons ";" in your program!!!

Input

Multiple test cases, the number of them T is given in the very first line, T<=99.

Each test case contains one line with a correct expression, without leading or trailing spaces.

Output

For each test case you should output one line contains the result of the expression without any leading zeros. You may assume this number is always a non-negative one.

Example

Input:
3
6*7
67-25
31+11

Output:
42
42
42

Score

Thanks to Jin Bin's suggestion, I've changed this problem from a classical one to a challenge one. Suppose the number of non-whitespace characters(ASCII 33 - 126) in your solution is K, the your score is floor(K3/1000)+1.

Note

The judge had something wrong and it has been fixed on Jul.1, 2008. Please accept my apology.


Added by:[Trichromatic] XilinX
Date:2007-11-03
Time limit:17s
Source limit:17000B
Languages:C C++ 4.0.0-8 PAS gpc PAS fpc JAVA
Resource:A copy of problem GALAXY, with language restrictions modified

hide comments
2009-11-25 16:26:29 Marcin Sasinowski
I sent my solution one more previous was accepted now it's sigsegv ? Did you update test and didn't run rejudge ?

Re by Xilinx: I don't think it's my fault.

Last edit: 2009-11-26 16:53:58
2009-10-04 22:50:54 bords0
Yes, I suspected that might be an error. I know next to nothing about TCL, and was surprised that is was so easy... :-)
2009-10-04 21:24:18 [Trichromatic] XilinX
I'm sorry that TCL language is not allowed for this problem!
SPOJ System © 2008-2010 Sphere Research Labs. All Rights Reserved.