#P16055. [CSPro 31] 坐标变换(其二)
[CSPro 31] 坐标变换(其二)
Background
Luogu’s testdata is only for non-official communication and is not official testdata. Official judging link: https://www.cspro.org/。
Problem Description
For a point on the Cartesian coordinate plane, Xiao P defines the following two operations:
- Scale by a factor of : the -coordinate becomes , and the -coordinate becomes .
- Rotate by : rotate the point counterclockwise around the origin by radians (). It is easy to see that after rotation, the new -coordinate is , and the new -coordinate is .
After fixing an operation sequence containing operations, Xiao P defines the following queries:
i j x y: the new coordinates of after applying operations ().
Given the operation sequence, compute the results of queries.
Input Format
Read input from standard input.
The input consists of lines.
The first line contains two positive integers and separated by spaces, representing the number of operations and the number of queries.
The next lines describe the operations in order. Each line contains an integer (the operation type) and a real number ( or ) separated by spaces, in the form 1 k (scale by a factor of ) or 2 θ (rotate by ).
The next lines describe the queries in order. Each line contains four integers , , , and separated by spaces, with meanings as described above.
Output Format
Write output to standard output.
Output lines. Each line contains two real numbers separated by spaces, representing the answer to the corresponding query.
10 5
2 0.59
2 4.956
1 0.997
1 1.364
1 1.242
1 0.82
2 2.824
1 0.716
2 0.178
2 4.094
1 6 -953188 -946637
1 9 969538 848081
4 7 -114758 522223
1 9 -535079 601597
8 8 159430 -511187
-1858706.758 -83259.993
-1261428.46 201113.678
-75099.123 -738950.159
-119179.897 -789457.532
114151.88 -366009.892
Hint
Sample Explanation
The 5th query only applies operation 8 to the input coordinates: scale by a factor of .
-coordinate: .
-coordinate: .
Because the exact computation method may differ, the program output may have a small difference from the true value. The sample output keeps only three decimal places.
Subtasks
- of the testdata satisfies: .
- All testdata satisfies:
- .
- All input coordinates are integers with absolute value not exceeding .
- For each single scaling operation, the factor .
- For any operation interval (), the product of scaling factors is within .
Scoring
If the absolute error between your floating-point output and the reference answer is at most , you get full score for that test point; otherwise you get .
Notes
- C/C++: It is recommended to use
doubleto store floating-point numbers, and usescanf("%lf", &x);for input andprintf("%f", x);for output. You may also usecinandcout. After#include <math.h>, you can use the trig functionscos()andsin(). - Python: You can directly use
print(x)to output a floating-point numberx. Afterfrom math import cos, sin, you can use the corresponding trig functions. - Java: It is recommended to use
doubleto store floating-point numbers. You can useSystem.out.print(x);for output. You can call trig functions withMath.cos()andMath.sin().
Translated by ChatGPT 5