Under construction

Still being built. Things may change

Computation - Task 9

Time limit1sMemory limit1024 MB

Summary
Write an instruction sequence in this restricted language that reads 16 reals and prints them in ascending order.
Level

Medium5 of 10

Topics
Sorting, Implementation
Solved
No attempts yet

Problem

Let xtx_t denote the result of the tt-th instruction. The permitted instructions, their syntax, and the result xtx_t are listed below.

NameOperatorParametersEffect
InputInoneRead a real number from the terminal and set it as xtx_t
OutputOiiPrint xix_i to the terminal, and set xt=xix_t = x_i
Addition+iji \quad jxt=xi+xjx_t = x_i + x_j
Adding constantCici \quad cxt=xi+cx_t = x_i + c
Negate-iixt=−xix_t = -x_i
Left shift<iki \quad kxt=xi⋅2kx_t = x_i \cdot 2^k
Right shift>iki \quad kxt=xi⋅2−kx_t = x_i \cdot 2^{-k}
SSiixt=s(xi)x_t = s(x_i)
ComparisonPiji \quad jxt=−1x_t = -1 if xi<xjx_i < x_j, xt=0x_t = 0 if xi=xjx_i = x_j, xt=1x_t = 1 if xi>xjx_i > x_j
MaxMiji \quad jxt=xix_t = x_i if xi>xjx_i > x_j, otherwise xt=xjx_t = x_j
Multiplication*iji \quad jxi=xi⋅xjx_i = x_i \cdot x_j

Here s(x)=11+e−xs(x) = \frac{1}{1 + e^{-x}}, where e=2.718281828459045…e = 2.718281828459045\ldots is the base of the natural logarithm.

The P, M, and * operators carry a penalty. See the grading section for details.

The operations have finite precision. Results are accurate only up to 90 digits after the decimal point, and the rest is rounded. Likewise, the argument cc of the adding constant instruction can have at most 90 digits in its decimal part.

For the left and right shift instructions, kk must be a non-negative integer not exceeding 10000.

For each instruction, the parameters ii and jj must be smaller than the current instruction number tt. Instructions run in order, one at a time.

Task 1: Given a,ba, b with ∣a∣,∣b∣≤109|a|, |b| \leq 10^9, where aa and bb have at most 9 digits in their decimal parts, compute −2a−2b-2a-2b.

Task 2: Given aa with ∣a∣≤109|a| \leq 10^9, where aa has at most 9 digits in its decimal part, compute 11+e17a\frac{1}{1+e^{17a}}.

Task 3: Given aa with ∣a∣≤109|a| \leq 10^9, where aa has at most 9 digits in its decimal part, compute −1-1 if a<0a < 0, 00 if a=0a = 0, and 11 if a>0a > 0.

Task 4: Given aa with ∣a∣≤109|a| \leq 10^9, where aa has at most 9 digits in its decimal part, compute the absolute value ∣a∣|a|.

Task 5: Given a1,…,a32a_1, \ldots, a_{32} with each ai∈{0,1}a_i \in \{0,1\}, read a1a2⋯a32a_1a_2 \cdots a_{32} as a binary number, where a1a_1 is the most significant bit and a32a_{32} is the least significant bit. Compute its value in base 10.

Task 6: Given an integer aa with 0≤a<2320 \leq a < 2^{32}, output 32 integers giving the binary representation of aa. Print the most significant bit first and the least significant bit last. If aa has fewer than 32 bits, add leading 0s.

Task 7: Given integers a,ba, b with 0≤a,b<2320 \leq a, b < 2^{32}, compute the bitwise XOR of aa and bb.

Task 8: Given aa with ∣a∣≤109|a| \leq 10^9, where aa has at most 9 digits in its decimal part, output a10\frac{a}{10}.

Task 9: Given a1,…,a16a_1, \ldots, a_{16} with ∣ai∣≤109|a_i| \leq 10^9, where each aia_i has at most 9 digits in its decimal part, print 16 real numbers that are the values a1,…,a16a_1, \ldots, a_{16} sorted in ascending order.

Task 10: Given integers a,b,ma, b, m with 0≤a,b<2320 \leq a, b < 2^{32} and 1≤m<2321 \leq m < 2^{32}, compute the remainder when a×ba \times b is divided by mm, that is, a×b mod ma \times b \bmod m.

Output

The ii-th line describes the ii-th instruction. First, output a letter for the operation. Then output zero or more integers for its parameters. Put a single space between the operator and each parameter.

You can output at most 10410^4 lines.

Examples1

  1. Example 1

    Input
    Expected output
    I
    + 1 1
    - 2
    I
    + 4 4
    - 5
    + 3 6
    - 7
    - 8
    O 9