P10402 "XSOI-R1" Gathering Points.

Description

Little T will give you an integer sequence of length $n$. You have a number $x$ in your hand, initially $0$. You can perform the following operations so that, in the end, the difference between $x$ and $c$ is less than $10^{-4}$. You may perform at most $k$ operations on $x$: - `add i`: add $a_i$ to the counter $x$, and then $a_i$ cannot be used in any operation anymore. - `sub i`: subtract $a_i$ from the counter $x$, and then $a_i$ cannot be used in any operation anymore. - `mul i`: multiply the counter $x$ by $a_i$, and then $a_i$ cannot be used in any operation anymore. - `sqrt i`: set $a_i$ to $\sqrt {a_i}$. Each $a_i$ can be square-rooted at most once. - `pow f`: change the counter $x$ into $x^f$, where $f$ can be a floating-point number. All $a_i$ must be used exactly once in an addition, subtraction, or multiplication operation on $x$. During the computation, the values of $a_i$ and $x$ must not exceed $10^{10}$. The problem guarantees that a solution exists. If there are multiple solutions, output any one of them. This problem requires high precision. Please improve the precision of your algorithm. ## Constraints **This problem uses bundled testdata.** - Subtask 0 (10 pts): $n \leq 5$, $k = n^2$. It is guaranteed that a solution can be obtained using only addition and subtraction. - Subtask 1 (20 pts): $n \leq 5$, $k = n^2$. It is guaranteed that a solution can be obtained using addition, subtraction, multiplication, and square root. - Subtask 2 (15 pts): $n \leq 10$, $a_i \leq 2$, $k = n + 1$. - Subtask 3 (55 pts): $k = n + 1$. For all testdata: $0 \leq n \leq 10^{5}$, $\sum_{i=1}^{n}{a_i} \le 10^{10}$, $0 \leq c \leq 10^{10}$.

Input Format

The first line contains three integers $n$, $k$, $c$. The second line contains $n$ integers, representing the sequence $a$.

Output Format

The first line contains an integer $g$, the total number of operations. The next $g$ lines contain your sequence of operations.

Explanation/Hint

**[Sample Explanation #1]** - Add $a_1$ to $x$. Now $x$ is $3$. - Add $a_2$ to $x$. Now $x$ is $6$. - Subtract $a_3$ from $x$. Now $x$ is $3$. - Subtract $a_4$ from $x$. Now $x$ is $0$. - Add $a_5$ to $x$. Now $x$ is $3$. **[Sample Explanation #2]** - Take the square root of $a_2$. Now $a = [1,\sqrt3,3]$. - Take the square root of $a_3$. Now $a = [1,\sqrt3,\sqrt3]$. - Add $a_1$ to $x$. Now $x$ is $1$. - Multiply $x$ by $a_2$. Now $x$ is $\sqrt3$. - Multiply $x$ by $a_3$. Now $x$ is $3$. **[Sample Explanation #3]** - Add $a_1$ to $x$. Now $x$ is $4$. - Add $a_2$ to $x$. Now $x$ is $9$. - Change $x$ into $x^2$. Now $x$ is $81$. - Subtract $a_3$ from $x$. Now $x$ is $77$. Translated by ChatGPT 5