|
|
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 JAVA PAS gpc PAS fpc |
| Resource: | A copy of problem GALAXY, with language restrictions modified |
|
|
|
|