아직 만들고 있는 페이지입니다.

이 페이지는 아직 만드는 중입니다. 보이는 내용은 바뀔 수 있습니다.

Computation - Task 4

면접 대비

시간 제한1초메모리 제한1024 MB

요약
제한된 명령 집합을 사용해 주어진 실수 a의 절댓값을 계산하는 문제다.
난이도

보통10점 중 4점

유형
구현, 수학, 시뮬레이션
정답자
아직 제출이 없습니다

문제

Given a task, you should write a program that solves the task using the instructions below. Let x_tx\_t denote the result of the tt-th instruction. The permitted instructions, the syntax, and the result x_tx\_t are given below:

NameOperatorParametersEffects
InputIN/ARead a real number from the terminal and make the number x_tx\_t
OutputOiiPrint x_ix\_i to the terminal, and x_t=x_ix\_t = x\_i
Addition+iji \quad jx_t=x_i+x_jx\_t = x\_i + x\_j
Adding constantCici \quad cx_t=x_i+cx\_t = x\_i +c
Negate-iix_t=−x_ix\_t = -x\_i
Left shift<iki \quad kx_t=x_i⋅2kx\_t = x\_i \cdot 2^k
Right shift>iki \quad kx_t=x_i⋅2−kx\_t = x\_i \cdot 2^{-k}
SSiix_t=s(x_i)x\_t = s(x\_i)
ComparisonPiji \quad jx\_t = \left\\{ \begin{array}{ll} -1 & \quad x\_i < x\_j \\\ 0 & \quad x\_i = x\_j \\\ 1 & \quad x\_i > x\_j \end{array} \right.
MaxMiji \quad jx\_t = \left\\{ \begin{array}{ll} x\_i & \quad x\_i > x\_j \\\ x\_j & \quad x\_i \leq x\_j \\\ \end{array} \right.
Multiplication*iji \quad jx_i=x_i⋅x_jx\_i = x\_i \cdot x\_j

Here, the definition of s(x)s(x) is given below where e=2.718281828459045…e = 2.718281828459045\ldots is the base of natural logarithm:

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

Notice there is a penalty for using the P, M, and * operators. See details below in the "grading" section.

For each instruction, the parameters ii and jj must be smaller than the current instruction number tt. The instructions are executed in the order, one by one.

The operations have finite precision: in particular, the results are only accurate up to 90 digits after the decimal point and the rest will be rounded. Similarly, the argument cc to the adding constant instruction can have at most 90 digits in its decimal part.

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

The ten tasks are given below:

  • 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 \left\\{ \begin{array}{ll} -1 & \quad a < 0\\\ 0 & \quad a = 0\\\ 1 & \quad a > 0 \end{array} \right..
  • 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 of aa, ∣a∣|a|.
  • Task 5: Given a_1,…,a_32a\_1,\ldots,a\_{32} where a_1,…,a_32∈0,1a\_1,\ldots,a\_{32} \in \\{0,1\\}, treat a_1a_2⋯a_32a\_1a\_2 \cdots a\_{32} as a binary number where a_1a\_1 is the most significant bit and a_32a\_{32} is the least significant bit, compute the corresponding value (in base 10).
  • Task 6: Given integer aa where 0≤a<2320 \leq a < 2^{32}, output 32 integers denoting aa in base 2 representation. The most significant bit should be printed first and the least significant bit should be printed last. If aa has less than 32 bits in its binary representation, 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 a_1,…,a_16a\_1,\ldots,a\_{16} where ∣a_i∣≤109|a\_i| \leq 10^9 and a_ia\_i has at most 9 digits in its decimal part, print 16 real numbers representing the result of sorting a_1,…,a_16a\_1,\ldots,a\_{16} in ascending order.
  • Task 10: Given integers a,b,ma,b,m where 0≤a,b<2320 \leq a,b < 2^{32}, 1≤m<2321 \leq m < 2^{32}, compute the remainder after dividing a×ba \times b by mm (i.e. compute a×b mod ma \times b \bmod m).

출력

The ii-th line describes the ii-th instruction: first, you should output a letter denoting the operation. Then output several (or zero) integers denoting the parameters to the operation. The operator and the parameters (and between parameters) should be separated by a single space.

You can output at most 10410^4 lines.

예제1

  1. 예제 1

    입력
    예상 출력
    I
    + 1 1
    - 2
    I
    + 4 4
    - 5
    + 3 6
    - 7
    - 8
    O 9