F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Calculator

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 283    Accepted Submission(s): 58


Problem Description
A simple 8-digit electronic calculator contains the following buttons: ¡°1234567890+-*/=¡± (no quotes). It can be divided into the following categories:
Digit: ¡°1234567890¡±
You can input any number with digital buttons (ignore leading zero). Notice, the LED of calculator can only display 8 digits. So when the number of digits large than eight, only the first eight digits will be retained. And when the number of one result¡¯s digits large than eight, error occurs.
Operator: ¡°+-*/¡±
For simplicity, all operations are integer operations. Some continuous operators, the last one is valid. When an operator button is pressed, the calculation before that will be completed.
 

Input
The first line is number of test cases. After that, each case consists of one line, containing a string means pressed button. The length of string is less than 100. There is no additional space.
 

Output
First output the case number. Then output the displayed number in the same line. If there is any error occurs, just print ¡°ERROR¡± please. Please follow the format of the sample output.
 

Sample Input
6 11+/2+ 11+*== 3==+5= 5=7=+8= 99999999+1-1= 1-99999999=
 

Sample Output
Case 1: 5 Case 2: 1331 Case 3: 8 Case 4: 15 Case 5: ERROR Case 6: -99999998
 

Author
xay@whu
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-26 23:52:06, Gzip enabled