以原点为圆心,给出圆上的一点,要求圆上的另外两点,使得这三个点的距离和最大,很容易想到这是一个等边三角形
然后有这两个公式 点a为已知点
a*b=|a|*|b|*cos(120);
x*x+y*y=r*r;
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
# include <iostream>
# include <cstdio>
# include <cstring>
# include <algorithm>
# include <cmath>
# include <queue>
# define LL long long
using namespace std ; int main ()
{
//freopen("in.txt","r",stdin) ;
int T ;
scanf("%d" , &T) ;
while(T--)
{
double x , y , x1 , y1 , x2 , y2 , a ,b ,c , r;
scanf("%lf %lf" , &x , &y) ;
r = sqrt(x*x + y*y) ;
a = r * r ;
b = r * r * y ;
c = (r*r*r*r-*x*x*r*r)/4.0 ;
y1 = (-1.0*b - sqrt(b*b - *a*c))/(*a) ;
y2 = (-1.0*b + sqrt(b*b - *a*c))/(*a) ;
if (fabs(x-) < 1e-)
{
x1 = -sqrt(r*r - y1*y1) ;
x2 = sqrt(r*r - y2*y2) ;
}
else
{
x1 = (-r*r/-y*y1)/x ;
x2 = (-r*r/-y*y2)/x ;
}
printf("%.3lf %.3lf %.3lf %.3lf\n" , x1 , y1 , x2 , y2) ; } return ;
}