#P10402. 「XSOI-R1」凑点
「XSOI-R1」凑点
Problem Description
Little T will give you an integer sequence of length . You have a number in your hand, initially . You can perform the following operations so that, in the end, the difference between and is less than .
You may perform at most operations on :
-
add i: add to the counter , and then cannot be used in any operation anymore. -
sub i: subtract from the counter , and then cannot be used in any operation anymore. -
mul i: multiply the counter by , and then cannot be used in any operation anymore. -
sqrt i: set to . Each can be square-rooted at most once. -
pow f: change the counter into , where can be a floating-point number.
All must be used exactly once in an addition, subtraction, or multiplication operation on .
During the computation, the values of and must not exceed . 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): , . It is guaranteed that a solution can be obtained using only addition and subtraction.
-
Subtask 1 (20 pts): , . It is guaranteed that a solution can be obtained using addition, subtraction, multiplication, and square root.
-
Subtask 2 (15 pts): , , .
-
Subtask 3 (55 pts): .
For all testdata: , , .
Input Format
The first line contains three integers , , .
The second line contains integers, representing the sequence .
Output Format
The first line contains an integer , the total number of operations.
The next lines contain your sequence of operations.
5 25 3
3 3 3 3 3
5
add 1
add 2
sub 3
sub 4
add 5
3 9 3
1 3 3
5
sqrt 2
sqrt 3
add 1
mul 2
mul 3
3 9 77
4 5 4
4
add 1
add 2
pow 2
sub 3
Hint
[Sample Explanation #1]
-
Add to . Now is .
-
Add to . Now is .
-
Subtract from . Now is .
-
Subtract from . Now is .
-
Add to . Now is .
[Sample Explanation #2]
-
Take the square root of . Now .
-
Take the square root of . Now .
-
Add to . Now is .
-
Multiply by . Now is .
-
Multiply by . Now is .
[Sample Explanation #3]
-
Add to . Now is .
-
Add to . Now is .
-
Change into . Now is .
-
Subtract from . Now is .
Translated by ChatGPT 5