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

NJU emulator

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 262144/262144 K (Java/Others)
Total Submission(s): 355    Accepted Submission(s): 95
Special Judge


Problem Description
"Dr.JYY, s86 instruction set, and NEMU, what should that remind you of?"
"Oh, no..."


NJU Emulator(a.k.a, NEMU) is the latest s86 architecture simulator developed by Dr. JYY. s86 is stack-style computer architecture, with its machine instructions only operating on the top element of the stack. The computation model of s86 includes a stack and a program of finite length. Each element in the stack is in $64$-bit unsigned integer type; We denote the stack as $S$ and size of the stack as $size(S)$, then the program consists of the instructions in the following table and must end with a terminating instruction.
When the s86 machine is running, the stack will first be initialized to empty, and then each instruction in the program will be executed in sequence until the last one is executed.
After an end instruction, the machine will output the top element of the stack and halt.



In the table, the $x$th element refers to the $x$th element from the top to the bottom of the stack, where the topmost element is the $0$th element.

Notably, all arithmetic operations(add, sub, mul) in the s86 instructions should be done modular $2^{64}$, i.e., when the arithmetic operation has a result of $X$, the result in the s86 instruction set should be $X'(0\leq X'<2^{64})$, and $X-X'$ is a multiple of $2^{64}$, it can be shown that such $X'$ exist for any integer $X$.

Now that Dr. JYY has finished the development of NEMU. To test the correctness of NEMU, Dr. JYY wants you to write a program using s86 instructions, so that when the program halts, it should output the given integer $N$.


 

Input
The first line contains a number $T(1\leq T\leq 10000)$, denoting the number of test cases.

Each test contains an integer $N(0\leq N< 2^{64)}$ in one line, denoting the number your program should output when halts.
 

Output
For each test case, you should output a piece of program consisting of s86 instructions in the form as in the table in the statement so that when your program halts, it should output the given integer $N$. Also, your program should contain at most 50 s86 instructions. It is guaranteed that there exists at least one such program under the limits of this problem. If any restriction in the instruction table is violated during the execution of your program, your answer would be considered incorrect.

If many programs satisfy the restriction, you should output any such program, which will be considered correct.
 

Sample Input
3 2 0 18446744073709551615
 

Sample Output
p1 add 0 end p1 dup sub 1 end p1 dup add 1 swap sub 1 end
 

Hint
The process of the execution of the last test case in the sample output is shown in the following table.

 

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-04-27 00:45:07, Gzip enabled