题目描述
Problem Description
Little T will give you an integer sequence of length $n$. You have a number $x$, initially set to $0$. You can perform the following operations to make the difference between $x$ and $c$ less than $10^{-4}$.
You can perform up to $k$ operations on $x$:
add i: Add $a_i$ to the counter $x$, and $a_i$ cannot be used in any further operations.sub i: Subtract $a_i$ from the counter $x$, and $a_i$ cannot be used in any further operations.mul i: Multiply the counter $x$ by $a_i$, and $a_i$ cannot be used in any further operations.sqrt i: Assign $a_i$ to $\sqrt{a_i}$, and each $a_i$ can only be square-rooted once.pow f: Change the counter $x$ to $x^f$, where $f$ can be a floating-point number.
Each $a_i$ must be used once in either an add, sub, or mul operation.
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 ensure your algorithm is precise.
Input Format
The first line contains three integers $n$, $k$, and $c$.
The second line contains $n$ integers representing the sequence $a$.
Output Format
The first line contains an integer representing the total number of operations $g$.
The next $g$ lines contain your sequence of operations.
Sample Input and Output
Sample Input #1
5 25 3
3 3 3 3 3
Sample Output #1
5
add 1
add 2
sub 3
sub 4
add 5
Sample Input #2
3 9 3
1 3 3
Sample Output #2
5
sqrt 2
sqrt 3
add 1
mul 2
mul 3
Sample Input #3
3 9 77
4 5 4
Sample Output #3
4
add 1
add 2
pow 2
sub 3
Notes
[Sample Explanation #1]
- $x$ adds $a_1$, now $x$ is $3$.
- $x$ adds $a_2$, now $x$ is $6$.
- $x$ subtracts $a_3$, now $x$ is $3$.
- $x$ subtracts $a_4$, now $x$ is $0$.
- $x$ adds $a_5$, now $x$ is $3$.
[Sample Explanation #2]
- $a_2$ is square-rooted, now $a=[1,\sqrt{3},3]$.
- $a_3$ is square-rooted, now $a=[1,\sqrt{3},\sqrt{3}]$.
- $x$ adds $a_1$, now $x$ is $1$.
- $x$ multiplies by $a_2$, now $x$ is $\sqrt{3}$.
- $x$ multiplies by $a_3$, now $x$ is $3$.
[Sample Explanation #3]
- $x$ adds $a_1$, now $x$ is $4$.
- $x$ adds $a_2$, now $x$ is $9$.
- $x$ becomes $x^2$, now $x$ is $81$.
- $x$ subtracts $a_3$, now $x$ is $77$.
Data Size and Constraints
This problem uses batched testing.
- Subtask 0 (10 pts): $n \leq 5$, $k = n^2$, guaranteed to be solvable using only add and sub operations.
- Subtask 1 (20 pts): $n \leq 5$, $k = n^2$, guaranteed to be solvable using add, sub, mul, and sqrt operations.
- Subtask 2 (15 pts): $n \leq 10$, $a_i \leq 2$, $k = n + 1$.
- Subtask 3 (55 pts): $k = n + 1$.
For all data: $0 \leq n \leq 10^5$, $\sum_{i=1}^{n}{a_i} \leq 10^{10}$, $0 \leq c \leq 10^{10}$.
输入格式
见题面 Input 部分
输出格式
见题面 Output 部分