22736_StackMachineProgrammer

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

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

Pro.ID

22736

Title

Stack Machine Programmer

Title链接

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

AC

0

Submit

0

Ratio

-

时间&空间限制

  • Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 65536/65536 K (Java/Others)
  • 描述

    Many ciphers can be computed much faster using various machines and automata. The trouble with such machines is that someone has to write programs for them. Just imagine, how easy it would be if we could write a program that would be able to write another programs. In this contest problem, we will (for a while) ignore the fact that such a "universal program" is not possible. And also another fact that most of us would lose our jobs if it existed.

    Your task is to write a program that will automatically generate programs for the stack machine defined in problem execute.

    输入

    The input contains several test cases. Each test case starts with an integer number N (1 ≤ N ≤ 5), specifying the number of inputs your program will process. The next N lines contain two integer numbers each, Vi and Ri. Vi (0 ≤ Vi ≤ 10) is the input value and Ri (0 ≤ Ri ≤ 20) is the required output for that input value. All input values will be distinct.

    Each test case is followed by one empty line. The input is terminated by a line containing one zero in place of the number of inputs.

    输出

    Description

    Many ciphers can be computed much faster using various machines and automata. The trouble with such machines is that someone has to write programs for them. Just imagine, how easy it would be if we could write a program that would be able to write another programs. In this contest problem, we will (for a while) ignore the fact that such a "universal program" is not possible. And also another fact that most of us would lose our jobs if it existed.

    Your task is to write a program that will automatically generate programs for the stack machine defined in problem execute.

    Input

    The input contains several test cases. Each test case starts with an integer number N (1 ≤ N ≤ 5), specifying the number of inputs your program will process. The next N lines contain two integer numbers each, Vi and Ri. Vi (0 ≤ Vi ≤ 10) is the input value and Ri (0 ≤ Ri ≤ 20) is the required output for that input value. All input values will be distinct.

    Each test case is followed by one empty line. The input is terminated by a line containing one zero in place of the number of inputs.

    Output

    For each test case, generate any program that produces the correct output values for all of the inputs. It means, if the program is executed with the stack initially containing only the input value Vi, after its successful execution, the stack must contain one single value Ri.

    Your program must strictly satisfy all conditions described in the specification of the problem execute, including the precise formatting, amount of whitespace, maximal program length, limit on numbers, stack size, and so on. Of course, the program must not generate a failure.

    Print one empty line after each program, including the last one.

    Sample Input

    3
    1 3
    2 6
    3 11

    1
    1 1

    2
    2 4
    10 1

    0

    Sample Output

    DUP
    MUL
    NUM 2
    ADD
    END

    END

    NUM 3
    MOD
    DUP
    MUL
    END

    Source

    样例输入

    3
    1 3
    2 6
    3 11

    1
    1 1

    2
    2 4
    10 1

    0

    样例输出

    DUP
    MUL
    NUM 2
    ADD
    END

    END

    NUM 3
    MOD
    DUP
    MUL
    END

    提示

    作者


    路过

    雷人

    握手

    鲜花

    鸡蛋

    最新评论

    返回顶部