#P1737. Flea Computer Calculator
Flea Computer Calculator
Flea Computer Calculator
In Flea Nation, every flea is a computing node with limited computational precision (up to 90 decimal places). Under the orders of the Flea King, n fleas are placed and numbered from 1 to n. Each node computes an output xₜ based on the outputs of previous nodes (with indices less than t) or terminal input. The available operations are given below in LaTeX format:
[ \begin{array}{|c|c|c|l|} \hline \textbf{Name} & \textbf{Operator} & \textbf{Operands} & \textbf{Result} \ \hline \text{Input Node} & I & \text{none} & x_t \text{ is read from the terminal} \ \text{Output Node} & O & i & x_t=x_i ; (\text{and output to terminal}) \ \text{Addition Node} & + & i,j & x_t=x_i+x_j \ \text{Offset Node} & C & i, c & x_t=x_i+c \ \text{Negation Node} & - & i & x_t=-x_i \ \text{Left Shift Node} & < & i, k & x_t=x_i \cdot 2^k \ \text{Right Shift Node} & > & i, k & x_t=x_i \cdot 2^{-k} \ \text{S-type Node} & S & i & x_t=s(x_i) \quad\text{where } s(x)=\frac{1}{1+e^{-x}} \ \text{Comparison Node} & P & i,j & x_t=\begin{cases}-1, & x_i<x_j\0, & x_i=x_j\1, & x_i>x_j\end{cases} \ \text{Max Node} & M & i,j & x_t=\begin{cases}x_i, & x_i>x_j\x_j, & x_i\le x_j\end{cases} \ \text{Multiplication Node} & * & i,j & x_t=x_i\cdot x_j \ \hline \end{array} ]
Due to technological limitations, operands (including the constant c in the offset node) must have at most 90 digits after the decimal point, and in the shift nodes the integer operand k must satisfy (0 \le k \le 10^4).
The Flea King has proposed 10 distinct computing tasks to test this flea computer. The tasks are as follows:
Task ID | Input | Input Constraints | Output |
---|---|---|---|
1 | a, b | |a|, |b| \le 10^9, with at most 9 decimal digits | \(-2a - 2b\) |
2 | a | |a| \le 10^9, with at most 9 decimal digits | \(\frac{1}{1+e^{17a}}\) |
3 | a | |a| \le 10^9, with at most 9 decimal digits | \(\begin{cases}-1, & a0\end{cases}\) |
4 | a | |a| \le 10^9, with at most 9 decimal digits | \(|a|\) (the absolute value of a) |
5 | a₁, a₂, \dots, a₃₂ | Each \(a_i \in \{0,1\}\) | Interpret the 32 binary digits as a binary number (most significant bit first) and output its integer value |
6 | a | 0 \(\le a < 2^{32}\), a is an integer | Output 32 integers, from the most significant bit to the least significant bit, representing the binary representation of a (pad with 0s if necessary) |
7 | a, b | 0 \(\le a, b < 2^{32}\); both are integers | Output the result of a XOR b |
8 | a | |a| \le 10^9, with at most 9 decimal digits | \(\frac{a}{10}\) |
9 | a₁, a₂, \dots, a₁₆ | Each |a_i| \le 10^9 with at most 9 decimal digits | Output the 16 real numbers sorted in ascending order (space-separated) |
10 | a, b, m | 0 \(\le a, b < 2^{32}\), \(1 \le m < 2^{32}\); all are integers | Output the remainder of \(a \cdot b\) divided by m |
Your task is to write a program that, based on the task ID provided as the first input, reads the corresponding input parameters and outputs the correct result. The first number in the input is the Task ID (an integer from 1 to 10). The subsequent input format is determined by the selected task as described above.
inputFormat
The input begins with an integer indicating the Task ID (from 1 to 10). Depending on the task, the following input values are provided in a single line (or multiple values separated by spaces):
Task 1: Two real numbers a and b. Task 2: One real number a. Task 3: One real number a. Task 4: One real number a. Task 5: 32 binary digits (each 0 or 1) separated by spaces. Task 6: One integer a. Task 7: Two integers a and b. Task 8: One real number a. Task 9: 16 real numbers separated by spaces. Task 10: Three integers a, b, and m.
outputFormat
Output the result as specified by the selected task. For tasks that require multiple outputs (tasks 6 and 9), output the values separated by spaces on a single line.
sample
1
1 2
-6
</p>