标题:帮忙看看,圆面积计算的问题
只看楼主
枫叶无痕
Rank: 2
等 级:论坛游民
帖 子:80
专家分:30
注 册:2011-2-10
结帖率:73.91%
已结贴  问题点数:20 回复次数:1 
帮忙看看,圆面积计算的问题
roblem A:Area of Circles

Time Limit:1000MS  Memory Limit:65536K
Total Submit:101 Accepted:24

Description

There are two circles on the plane. Now you must to calculate the area which they cover the plane. For example, in Figure 1, the area of the red region is the answer of this problem.



Input

The input contains multiple test cases. The first line contains an integer T describing the number of test cases. Each case contains two lines. One line describes one circle. For each line has three integers x, y, r, indicating the coordinate of the centre and radius. All the numbers are separated by spaces. All the input integers are within the range of [-1000, 1000].

Output

For each test case, output one line containing a number with 3 digits after decimal point representing the answer describing above.

Sample Input


2
2 2 2 1 4 3
2 2 1 -2 -2 1
Sample Output


32.462
6.283



帮忙看看,为什么在acm.zstu.总是不过

下面是代码

#include<stdio.h>
#include<math.h>
main()
{
    float r1,r2,x1,x2,y1,y2;
    int t;
    while(scanf("%d",&t)!=EOF)
    {while(t--)
    {
        scanf("%f%f%f%f%f%f",&x1,&y1,&r1,&x2,&y2,&r2);
        float g,h;
        g=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
        h=r1*r1-r2*r2;
        float d1,d2,s1,s2,s;
        if(g>=r1+r2)
        s=acos(-1)*r1*r1+acos(-1)*r2*r2;
        else
        {
            if(g<=fabs(r1-r2))
            {
                if(r1>=r2)
                s=acos(-1)*r1*r1;
                else
                s=acos(-1)*r2*r2;
            }
            else
            {
                d1=(g+h/g)/2.0;
                d2=(g-h/g)/2.0;
                s1=acos(d1/r1)*r1*r1-d1*(sqrt(r1*r1-d1*d1));
                s2=acos(d2/r2)*r2*r2-d2*(sqrt(r2*r2-d2*d2));
                s=acos(-1)*r1*r1+acos(-1)*r2*r2-s1-s2;
            }
        }
        printf("%.3f\n",s);
    }
    }
}
搜索更多相关主题的帖子: example multiple first describes 计算 
2011-07-22 14:04
刘定邦
Rank: 10Rank: 10Rank: 10
等 级:青峰侠
帖 子:687
专家分:1570
注 册:2010-9-21
得分:20 
不懂英文。
2011-07-22 14:12



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-345864-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.294213 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved