# zoj3806Incircle and Circumcircle

 1 #include <iostream>
2 #include<cstdio>
3 #include<cstring>
4 #include<algorithm>
5 #include<stdlib.h>
6 #include<vector>
7 #include<cmath>
8 #include<queue>
9 #include<set>
10 using namespace std;
11 #define N 100000
12 #define LL long long
13 #define INF 0xfffffff
14 const double eps = 1e-10;
15 const double pi = acos(-1.0);
16 const double inf = ~0u>>2;
17 int dcmp(double x)
18 {
19     if(fabs(x)<eps) return 0;
20     return x<0?-1:1;
21 }
22 int cal(double x,double R,double r)
23 {
24     if(dcmp(R*R-x*x)<0) return 0;
25     double a = sqrt(2*R*R+2*R*sqrt(R*R-x*x));
26     double b = a;
27     double c = 2*x;
28     double s = (a+b+c)/2;
29     double tt = (s-a)*(s-b)*(s-c)/s;
30     if(dcmp(tt)<0) return 0;
31     double tr = sqrt(tt);
32     if(dcmp(tr-r)>=0) return 1;
33     return 0;
34 }
35 int main()
36 {
37     double r1,r2;
38     while(scanf("%lf%lf",&r1,&r2)!=EOF)
39     {
40         if(dcmp(2*r1-r2)>0)
41         {
42             puts("NO Solution!");
43             continue;
44         }
45         double rig = sqrt(3.0)*r2,lef = 0,mid;
46         while(rig-lef>eps)
47         {
48             mid = (lef+rig)/2;
49             if(cal(mid,r2,r1))
50                 rig = mid;
51             else lef = mid;
52         }
53        // printf("%f\n",rig);
54         double a = sqrt(2*r2*r2+2*r2*sqrt(r2*r2-rig*rig));
55         double b = a;
56         double c = 2*rig;
57         printf("%.15f %.15f %.15f\n",a,b,c);
58     }
59     return 0;
60 }
View Code

posted @ 2014-09-10 10:32  _雨  阅读(300)  评论(0编辑  收藏  举报