L - Points on Cycle(旋转公式)
L - Points on Cycle
Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64uDescription
There is a cycle with its center on the origin.
Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other
you may assume that the radius of the cycle will not exceed 1000.
Now give you a point on the cycle, you are to find out the other two points on it, to maximize the sum of the distance between each other
you may assume that the radius of the cycle will not exceed 1000.
Input
There are T test cases, in each case there are 2 decimal number representing the coordinate of the given point.
Output
For each testcase you are supposed to output the coordinates of both of the unknow points by 3 decimal places of precision
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.
Alway output the lower one first(with a smaller Y-coordinate value), if they have the same Y value output the one with a smaller X.
NOTE
when output, if the absolute difference between the coordinate values X1 and X2 is smaller than 0.0005, we assume they are equal.Sample Input
2
1.500 2.000
563.585 1.251
Sample Output
0.982 -2.299 -2.482 0.299
-280.709 -488.704 -282.876 487.453
//题目意思,在一个圆心在原点的圆上,给你一个点的坐标,求圆内接正三角形的另两个点坐标
//这周做题真的很蛋疼,什么都一次过不了,什么奇奇怪怪的错误都有。
这题用旋转公式,弧度传4*pi/3 ,竟然是错的,必须传-2*pi/3,真是不懂,好烦!!!
1 #include <iostream>
2 #include <stdio.h>
3 #include <math.h>
4 using namespace std;
5
6 const double pi=3.141592654;
7
8 int main()
9 {
10 int t;
11 scanf("%d",&t);
12 double x,y;
13 double x1,y1,x2,y2;
14 while (t--)
15 {
16 scanf("%lf%lf",&x,&y);
17 x1=x*cos(2*pi/3)-y*sin(2*pi/3);
18 y1=x*sin(2*pi/3)+y*cos(2*pi/3);
19 x2=x*cos(-2*pi/3)-y*sin(-2*pi/3);
20 y2=x*sin(-2*pi/3)+y*cos(-2*pi/3);
21
22 if (y1<y2||(y1==y2&&x1<x2))//题目要求,y值小的在前面,y一样x小的在前面
23 printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
24 else
25 printf("%.3lf %.3lf %.3lf %.3lf\n",x2,y2,x1,y1);
26 }
27 return 0;
28 }