hdu 1700 Points on Cycle<计算几何>

链接: http://acm.hdu.edu.cn/showproblem.php?pid=1700

题意:给出一个圆心在原点的圆上一点,求此圆上另外两点使其构成三角形周长最长。

思路: 圆内的等边三角形周长最长。

View Code
 1 #include <stdio.h>
 2  #include <math.h>
 3  #define PI 3.1415926
 4  
 5  int main()
 6  {
 7      double x,y,x1,y1,x2,y2,cosx,a,b,c,r,delta;
 8      int t;
 9      scanf("%d",&t);
10      while(t--){
11          scanf("%lf%lf",&x,&y);
12          r=sqrt(x*x+y*y);
13          a=r*r;
14          b=r*r*y;
15          c=r*r*r*r/4-x*x*r*r;
16          delta=b*b-4*a*c;
17          y1=(-1*b-sqrt(delta))/(2*a);
18          y2=(-1*b+sqrt(delta))/(2*a);
19          if(x==0){
20              x1=-sqrt(r*r-y1*y1);
21              x2=sqrt(r*r-y2*y2);
22          }
23          else{
24              x1=(-1*r*r/2-y*y1)/x;
25              x2=(-1*r*r/2-y*y2)/x;
26          }
27          printf("%.3lf %.3lf %.3lf %.3lf\n",x1,y1,x2,y2);
28      }
29      return 0;
30  }
posted @ 2012-09-14 17:05  淡墨æ末央  阅读(230)  评论(0编辑  收藏  举报