zoukankan      html  css  js  c++  java
  • hdu 3264 09 宁波 现场 E

    Description

    The city of M is a famous shopping city and its open-air shopping malls are extremely attractive. During the tourist seasons, thousands of people crowded into these shopping malls and enjoy the vary-different shopping. 

    Unfortunately, the climate has changed little by little and now rainy days seriously affected the operation of open-air shopping malls―it’s obvious that nobody will have a good mood when shopping in the rain. In order to change this situation, the manager of these open-air shopping malls would like to build a giant umbrella to solve this problem. 

    These shopping malls can be considered as different circles. It is guaranteed that these circles will not intersect with each other and no circles will be contained in another one. The giant umbrella is also a circle. Due to some technical reasons, the center of the umbrella must coincide with the center of a shopping mall. Furthermore, a fine survey shows that for any mall, covering half of its area is enough for people to seek shelter from the rain, so the task is to decide the minimum radius of the giant umbrella so that for every shopping mall, the umbrella can cover at least half area of the mall. 
     

    Input

    The input consists of multiple test cases. 
    The first line of the input contains one integer T (1<=T<=10), which is the number of test cases. 
    For each test case, there is one integer N (1<=N<=20) in the first line, representing the number of shopping malls. 
    The following N lines each contain three integers X,Y,R, representing that the mall has a shape of a circle with radius R and its center is positioned at (X,Y). X and Y are in the range of [-10000,10000] and R is a positive integer less than 2000. 
     

    Output

    For each test case, output one line contains a real number rounded to 4 decimal places, representing the minimum radius of the giant umbrella that meets the demands.
     

    Sample Input

    1 2 0 0 1 2 0 1
     

    Sample Output

    2.0822
     
    计算圆相交面积(两圆扇形-中间的四边形),从所有圆圆心出发,二分求直径,然后选择最小即可
    这是萌萌smilewsw代码: 
    #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
    ",minn);
        }
        return 0;
    }
    

      

  • 相关阅读:
    JQuery Smart UI 简介 (二) — 演示Demo For .Net[附下载][下载文件已更新]
    JQuery Smart UI 简介(四) — 强大的适用性&存在问题【项目使用性介绍】
    告别aspx,高性能快捷开发 — JQuery Smart UI 快捷开发实例应用(一)入门【前篇】
    JQuery Smart UI 1.0正式发布&Smart UI网站上线【演示、API、下载等】
    JQuery Smart UI 简介(六) — 框架设计【后篇】(数据接口、后台框架)[简介系列完结]
    在SSRS报表中,显示图片
    安装MS SQL Server 2008 “性能计数器注册表配置单元一致性”失败的解决办法
    EventHandler常用业务分析(转载)
    在Windows 7 X64系统中安装SharePoint 2010 Beta版
    SharePoint 2010 Beta 中文版 下载地址
  • 原文地址:https://www.cnblogs.com/xuesu/p/4089989.html
Copyright © 2011-2022 走看看