Nils has developed a new programming language, Nils++!
A Nils++ program consists of multiple lines. Each line is either blank (in which case it will be ignored), or contains exactly one statement. Due to computing limitations, there cannot be more than
A Nils++ interpreter uses
There are only six different types of statements:
ADD A B C
Compute the sum of the values in cells A and B, and store the result in cell C.NEG A B
Negate the value in cell A, and store the result in cell B.ABS A B
Calculate the absolute value of the value in cell A, and store the result in cell B.SGN A B
Calculate the sign function of the value in cell A, and store the result in cell B.CLR A B
If the value in cell A is nonzero, set the value in cell B to . Otherwise, if the value in cell A is , then do nothing.OUT A
Output the value in cell A.
Note that A
, B
and C
represent integers between
The output of the program is the sequence of values outputted using the OUT
statement, in the order that they were outputted.
In order to demonstrate the versatility of his programming language, Nils wishes to create various Nils++ programs that solve different tasks. The seven tasks are listed below:
Task 1: EQUALS
- Initially, cell 1 contains an integer
, and cell 2 contains an integer . All other cells contain the integer . .- At least one of
and is nonzero. - You should output a single integer, equal to
if , and if .
Task 2: MAX
- Initially, cell 1 contains an integer
, and cell 2 contains an integer . All other cells contain the integer . .- You should output a single integer, equal to
.
Task 3: PRODUCT
- Initially, cell 1 contains an integer
, and cell 2 contains an integer . All other cells contain the integer . .- You should output a single integer, equal to
.
Task 4: GCD
- Initially, cell 1 contains an integer
, and cell 2 contains an integer . All other cells contain the integer . .- You should output a single integer, equal to
.
Task 5: XOR
- Initially, cell 1 contains an integer
, and cell 2 contains an integer . All other cells contain the integer . .- You should output a single integer, equal to
. Here, denotes the bitwise XOR operator.
Task 6: PRIMES
- Initially, cell 1 contains an integer
. All other cells contain the integer . .- You should output a single integer, equal to number of primes which are less than or equal to
.
Task 7: SORT
- Initially, cells
to contain the integers respectively. All other cells contain the integer . .- You should output
integers. The output of the program should be the result when is sorted.
Experimentation
You will be provided with a Nils++ interpreter for local testing purposes. There are two versions of the interpreter, one written in Python and one written in C++.
Both of the interpreters read from standard input and write to standard output.
The first line of input should contain a single integer,
The second line should contain
The remaining lines of input should contain the Nils++ program.
Both interpreters will print out all values outputted using the OUT
statement, in the order they were outputted, with one integer on each line.
Note that the interpreters are intended solely for testing purposes, and as such may not parse poorly-formatted input properly.
Subtasks
Subtask | Points | Task | Additional Constraints |
---|---|---|---|
- | |||
- | |||
- | |||
- | |||
- | |||
- | |||
- |
Input Specification
The only line contains a single integer between
Output Specification
Output one or more lines. Each line should be blank, or contain exactly one statement in the described format. There should be at most
Sample Input
1
Sample Output
ADD 1 2 1
NEG 2 3
SGN 3 3
ABS 3 3
CLR 1 3
OUT 3
Explanation
This program is supposed to output whether two numbers are equal. This sample output would not be accepted, and is intended only as a clarification of the behaviour of each statement.
Let's assume that initially, cell
- Calculate
. Then, set to . - Calculate
. Then, set to . - Calculate
. Then, set to . - Calculate
. Then, set to . - Since
is nonzero, set to . - Output
.
The actual output of the program is Wrong Answer
verdict.
Comments