bnu4067美丽的花环

美丽的花环

Time Limit: 1000ms
Memory Limit: 65536KB
64-bit integer IO format:  %lld      Java class name:  Main
Special Judge
Type: 
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •                   
  •  学校的草坪上最近种植了一些漂亮的花卉,所有的花围成了一个环形(内径为r,外径为R,0 <r < R) 。原来这片地上有一个用于喷灌的喷头。这个喷头可以为半径K以内的植物提供水。(如图) 

    现在,HK请你帮忙计算一下,花构成的环形当中有多大面积的可以由喷头提供灌溉。 

    Input

     输入数据只有两行。 
    格式为(中间使用空格隔开) 

    x1 y1 R r 
    x2 y2 K 

    花环中心在(x1,y1) ,外径为R,内径为r。 
    喷头的位置为(x2,y2),覆盖范围为K。 
    其中,x1,y1,R,r,x2,y2,K均为实数。

    Output

     输出题目描述中所求面积(保留2位小数)。

    Sample Input

    5 5 20 10
    2 2 20

    Sample Output

    773.09

    Hint

    π的值请取:3.1415926或acos(-1.0) 

    Source

    直接套模板
    #include<iostream>
    #include<cstdio>
    #include<cstring>
    #include<cstdio>
    #include<cmath>
    #include<algorithm>
    #define esp 1e-8
    
    using namespace std;
    
    struct node{
        double x,y;
        double r;
    };
    double calArea(node c1, node c2)
    {
        double d;
        double s,s1,s2,s3,angle1,angle2;
    
        d=sqrt((c1.x-c2.x)*(c1.x-c2.x)+(c1.y-c2.y)*(c1.y-c2.y));
        if(d>=(c1.r+c2.r))//两圆相离
            return 0;
        if((c1.r-c2.r)>=d)//两圆内含,c1大
            return acos(-1.0)*c2.r*c2.r;
        if((c2.r-c1.r)>=d)//两圆内含,c2大
            return acos(-1.0)*c1.r*c1.r;
    
        angle1=acos((c1.r*c1.r+d*d-c2.r*c2.r)/(2*c1.r*d));
        angle2=acos((c2.r*c2.r+d*d-c1.r*c1.r)/(2*c2.r*d));
    
        s1=angle1*c1.r*c1.r;s2=angle2*c2.r*c2.r;
        s3=c1.r*d*sin(angle1);
        s=s1+s2-s3;
        return s;
    }
    int main()
    {
        node cir1,cir2,cir3;
        double R;
        scanf("%lf%lf%lf%lf",&cir1.x,&cir1.y,&cir1.r,&R);
        scanf("%lf%lf%lf",&cir3.x,&cir3.y,&cir3.r);
        cir2.x=cir1.x;
        cir2.y=cir1.y;
        cir2.r=R;
        double s=calArea(cir1,cir3)-calArea(cir2,cir3);
        printf("%.2lf\n",s);
        return 0;
    }
    



    评论
    添加红包

    请填写红包祝福语或标题

    红包个数最小为10个

    红包金额最低5元

    当前余额3.43前往充值 >
    需支付:10.00
    成就一亿技术人!
    领取后你会自动成为博主和红包主的粉丝 规则
    hope_wisdom
    发出的红包
    实付
    使用余额支付
    点击重新获取
    扫码支付
    钱包余额 0

    抵扣说明:

    1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
    2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

    余额充值