标签:des style blog http color io os ar java
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1876 Accepted Submission(s): 567
1 #include<cstdio> 2 #include<cmath> 3 #include<algorithm> 4 #include<iostream> 5 using namespace std; 6 7 struct circle 8 { 9 double x,y,r; 10 }; 11 double dist(circle a,circle b) 12 { 13 return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y)); 14 } 15 int main() 16 { 17 circle a,b; 18 double d,p,area,sb,sa; 19 while(scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&a.r,&b.x,&b.y,&b.r)!=EOF) 20 { 21 d=dist(a,b); 22 double rr=min(a.r,b.r); 23 if(d<=abs(a.r-b.r)) //内含或者内切 24 area=acos(-1.0)*rr*rr; 25 else 26 if(d>=a.r+b.r) 27 area=0.0; 28 else{ 29 p=(a.r+b.r+d)/2.0; 30 sa=acos((a.r*a.r+d*d-b.r*b.r)/(2.0*a.r*d)); 31 sb=acos((b.r*b.r+d*d-a.r*a.r)/(2.0*b.r*d)); 32 area=sa*a.r*a.r+sb*b.r*b.r-2*sqrt(p*(p-a.r)*(p-b.r)*(p-d)); 33 } 34 printf("%.3lf\n",area); 35 } 36 return 0; 37 }
hdu---(Tell me the area)(几何/三角形面积以及圆面积的一些知识)
标签:des style blog http color io os ar java
原文地址:http://www.cnblogs.com/gongxijun/p/4001228.html