Under construction

Still being built. Things may change

Computation - Task 6

Time limit1sMemory limit1024 MB

Summary
Write an instruction-set program for ten fixed tasks, including XOR, a*b mod m, and sorting 16 reals, using only the listed operators.
Level

Medium6 of 10

Topics
Implementation, Bit manipulation, Sorting
Solved
No attempts yet

Problem

You need to write a program that solves the task using the instructions below. Let xtx_t denote the result of the tt-th instruction. The permitted instructions, the syntax, and the result xtx_t are given below.

NameOperatorParametersEffect
InputIN/AReads a real number from the terminal and sets xtx_t to that number
OutputOiiPrints xix_i to the terminal, and 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, 00 if xi=xjx_i = x_j, 11 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

The function s(x)s(x) is defined below, where e=2.718281828459045…e = 2.718281828459045\ldots is the base of the natural logarithm.

s(x)=11+e−x.s(x) = \frac{1}{1 + e^{-x}}.

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

Instructions run in order, one at a time. For each instruction, the parameters ii and jj must be smaller than the current instruction number tt. Operations have finite precision. Results are accurate only up to 90 digits after the decimal point, and the rest is rounded. The argument cc of the adding constant instruction has 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.

Tasks

  • Task 1: Given a,ba, b where ∣a∣,∣b∣≤109|a|, |b| \leq 10^9 and a,ba, b have at most 9 digits in their decimal parts, compute −2a−2b-2a-2b.
  • Task 2: Given aa where ∣a∣≤109|a| \leq 10^9 and aa has at most 9 digits in its decimal part, compute 11+e17a\frac{1}{1+e^{17a}}.
  • Task 3: Given aa where ∣a∣≤109|a| \leq 10^9 and 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 where ∣a∣≤109|a| \leq 10^9 and 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} where each ai∈{0,1}a_i \in \{0,1\}, treat 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 where 0≤a<2320 \leq a < 2^{32}, output 32 integers giving aa in base 2. 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 where 0≤a,b<2320 \leq a, b < 2^{32}, compute the bitwise XOR of aa and bb.
  • Task 8: Given aa where ∣a∣≤109|a| \leq 10^9 and aa has at most 9 digits in its decimal part, output a10\frac{a}{10}.
  • Task 9: Given a1,…,a16a_1, \ldots, a_{16} where ∣ai∣≤109|a_i| \leq 10^9 and each aia_i has at most 9 digits in its decimal part, print 16 real numbers that are a1,…,a16a_1, \ldots, a_{16} sorted in ascending order.
  • Task 10: Given integers a,b,ma, b, m where 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. Separate the operator and the parameters, and separate the parameters from each other, with a single space.

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