Submit | All submissions | Best solutions | Back to list |
EXPR2 - Analyse Simple Arithmetical Expressions |
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. (In the judge data, 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.
Note 2
Sorry to some users, but the C function "system()" is prohibited in this problem. Judge has been modified. Use problem CE to practice your programming skills without any(?) restrictions.
Added by: | Fudan University Problem Setters |
Date: | 2007-11-03 |
Time limit: | 2s |
Source limit: | 17000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | C CPP JAVA PAS-GPC PAS-FPC |
Resource: | A copy of problem GALAXY, with language restrictions modified |
hide comments
|
|||||
2013-06-27 09:47:58 pika_pika
how the hell to write a java code without ';'.. just to include a package one would need ';' |
|||||
2013-03-01 21:46:58 gskhirtladze
can expression be <expression>::=<num><oper><num><oper><num><oper><num> or something like this ? i mean that number of operations (+,-,*) is > 1. |
|||||
2012-09-14 06:38:50 Amit Kumar
What is max size of expression? |
|||||
2012-06-22 09:55:20 Mandar
are there spaces between numbers and operators?? |
|||||
2012-02-05 11:08:54 Ahmed Abdel Samad
is this an integer division? please add test cases for division. edit: Sorry I thought the operators were +,-,* and / . Last edit: 2012-02-06 19:50:02 |
|||||
2011-10-07 03:36:40 blashyrkh
Hey, judge assigned me score 0 and put to the first place. It's a bug, score should be 2745. Submission id is 5277808. Edit: now it's ok, thanks Last edit: 2011-06-22 11:48:03 |
|||||
2011-10-07 03:36:40 Sankalp Raghav
@ vikash a zero :| |
|||||
2011-10-07 03:36:40 Junkyard
what we have to print if output is 0 |