标签:des blog io ar os sp for div on
Description
Input
Output
Sample Input
Sample Output
#include <cstdio> #include <cstdlib> #include <iostream> #include <cstring> #include <cmath> #include <algorithm> #define eps 1e-10 #define PI acos(-1.0) using namespace std; struct point { double x,y; }; struct circle { point c; double r; }ci[50]; double dis(point p1,point p2) { return sqrt((p1.x-p2.x)*(p1.x-p2.x)+(p1.y-p2.y)*(p1.y-p2.y)); } double area(point p,double R,circle a) { double d=dis(p,a.c),pp; double sa=0,ang1,ang2; ang1=acos((a.r*a.r+d*d-R*R)/(2*a.r*d)); ang2=acos((R*R+d*d-a.r*a.r)/(2*R*d)); pp=R*sin(ang2); sa=ang1*a.r*a.r+ang2*R*R-pp*d; return sa; } double qsearch(point p,circle a) { double d=dis(p,a.c); double l=d,r=sqrt(d*d+a.r*a.r),mid; double ans=PI*a.r*a.r/2; while(l+eps<r) { mid=(l+r)/2; if(fabs(area(p,mid,a)-ans)<eps) return mid; else if(ans<area(p,mid,a)) r=mid; else l=mid; } return l; } int main() { int t,n; point p; circle a; p.x=2,p.y=0; a.c.x=0,a.c.y=0,a.r=1; scanf("%d",&t); while(t--) { scanf("%d",&n); for(int i=0;i<n;i++) scanf("%lf%lf%lf",&ci[i].c.x,&ci[i].c.y,&ci[i].r); double minn; for(int i=0;i<n;i++) { double maxn=ci[i].r/sqrt(2.0); for(int j=0;j<n;j++) { if(i==j) continue; maxn=max(maxn,qsearch(ci[i].c,ci[j])); } if(i==0) minn=maxn; else minn=min(minn,maxn); } printf("%.4f\n",minn); } return 0; }
hdu 3264 09 宁波 现场 E - Open-air shopping malls 计算几何 二分
标签:des blog io ar os sp for div on
原文地址:http://www.cnblogs.com/xuesu/p/4089989.html