hdu 1700 (圆的内接三角形 要周长最大)

以原点为圆心,给出圆上的一点,要求圆上的另外两点,使得这三个点的距离和最大,很容易想到这是一个等边三角形
然后有这两个公式 点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

 

 1 # include <iostream>
 2 # include <cstdio>
 3 # include <cstring>
 4 # include <algorithm>
 5 # include <cmath>
 6 # include <queue>
 7 # define LL long long
 8 using namespace std ;
 9 
10 
11 int main ()
12 {
13     //freopen("in.txt","r",stdin) ;
14     int T ;
15     scanf("%d" , &T) ;
16     while(T--)
17     {
18         double x , y , x1 , y1 , x2 , y2 , a ,b ,c , r;
19         scanf("%lf %lf" , &x , &y) ;
20         r = sqrt(x*x + y*y) ;
21         a = r * r ;
22         b = r * r * y ;
23         c = (r*r*r*r-4*x*x*r*r)/4.0 ;
24         y1 = (-1.0*b - sqrt(b*b - 4*a*c))/(2*a) ;
25         y2 = (-1.0*b + sqrt(b*b - 4*a*c))/(2*a) ;
26         if (fabs(x-0) < 1e-7)
27         {
28             x1 = -sqrt(r*r - y1*y1) ;
29             x2 = sqrt(r*r - y2*y2) ;
30         }
31         else
32         {
33             x1 = (-r*r/2-y*y1)/x ;
34             x2 = (-r*r/2-y*y2)/x ;
35         }
36         printf("%.3lf %.3lf %.3lf %.3lf\n" , x1 , y1 , x2 , y2) ;
37 
38     }
39 
40     return 0 ;
41 }
View Code

 

posted @ 2015-09-20 14:40  __Meng  阅读(1086)  评论(0编辑  收藏  举报