21974_Calculator

2022-5-16 18:20| 发布者: Hocassian| 查看: 21| 评论: 0|原作者: 肇庆学院ACM合集

摘要:
C:\Users\Administrator\Downloads\2019-10-12-10-14-4-895068202799-Problem List-采集的数据-后羿采集器.html

Pro.ID

21974

Title

Calculator

Title链接

http://10.20.2.8/oj/exercise/problem?problem_id=21974

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 400/200 MS (Java/Others)     Memory Limit: 32768/32768 K (Java/Others)
  • 描述

    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.

    Example of type "11+/2+"

    Button1
    1+
    /2
    +
    Display1
    111111
    25

    Equal-sign: "="

    If the second operand is missing, you can think it equal the first operand. More than one continuous equal-sign means repeat the operation. You can observe the following examples.

    Example of type "11+*=="

    Button
    1
    1
    +
    *
    =
    =
    Display
    1
    11
    11
    11
    121
    1331

    Example of type "3==+5="

    Button
    3
    =
    =
    +
    5
    =
    Display
    3
    33358

    Example of type "5=7=+8="

    Button
    5
    =7=+8
    =
    Display
    55777815

    输入

    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.

    输出

    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.

    Example of type "11+/2+"

    Button1
    1+
    /2
    +
    Display1
    111111
    25

    Equal-sign: "="

    If the second operand is missing, you can think it equal the first operand. More than one continuous equal-sign means repeat the operation. You can observe the following examples.

    Example of type "11+*=="

    Button
    1
    1
    +
    *
    =
    =
    Display
    1
    11
    11
    11
    121
    1331

    Example of type "3==+5="

    Button
    3
    =
    =
    +
    5
    =
    Display
    3
    33358

    Example of type "5=7=+8="

    Button
    5
    =7=+8
    =
    Display
    55777815
    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 number of display in the same line. If there is any error occurs, just print

    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

    Source

    样例输入

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

    样例输出

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

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部