Points on Cycle
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 1990 Accepted Submission(s): 719
Problem Description
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.
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.
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
Source
2007省赛集训队练习赛(1)
题目大意:给你一个点要你以这点与原点为中心的园上找到2个距离最长的点
思路:就是一个正三角形ps:注意double型的精度判断
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
#define inf 0xffffff
#define maxn 1005
#define Pi 3.1415926535987932
struct point
{
double x,y;
};
bool fun(point a,point b)
{
if(fabs(a.y - b.y)<0.0000001 && a.x <b.x) return true;
if(a.y < b.y) return true;
return false;
}
void fun2(point a,point b)
{
printf("%.3f %.3f %.3f %.3f\n",a.x,a.y,b.x,b.y);
}
int main()
{
int t;
point a,b,c;
scanf("%d",&t);
while(t--)
{
scanf("%lf%lf",&a.x,&a.y);
double q = atan2(a.y,a.x);
double r = hypot(a.x,a.y);
c.x = -r*cos(q+Pi/3);
c.y = -r*sin(q+Pi/3);
b.x = -r*cos(q-Pi/3);
b.y = -r*sin(q-Pi/3);
if(fun(b,c)) fun2(b,c);
else fun2(c,b);
}
return 0;
}