Tell me the area

Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 1876    Accepted Submission(s): 567

Problem Description
    There
are two circles in the plane (shown in the below picture), there is a
common area between the two circles. The problem is easy that you just
tell me the common area.
 
Input
There
are many cases. In each case, there are two lines. Each line has three
numbers: the coordinates (X and Y) of the centre of a circle, and the
radius of the circle.
 
Output
For
each case, you just print the common area which is rounded to three
digits after the decimal point. For more details, just look at the
sample.
 
Sample Input
0 0 2
2 2 1
 
Sample Output
0.108
 
Author
wangye
 
Source
 
对于平面内,任意两个圆,存在这些关系: 内含和内切,以及相交,外切和外离。
(1)对于内切,我们只需要求出面积最小圆的面积,
(2)对于外切及外离,得到的面积必然为0.0;
 (3)对于相交,那么我们需要求出这些
          : 知道两点坐标: 求出dist两点之间的距离;
              知道三边,可以求出三边对应的角度: a^2+b^2-2*a*b*cos(g)=dist^2;
        对于四边形的面积: sm=s3(三角形的面积)*2;
                                  s3=sqrt(p*(p-r1)*(p-r2)*(p-d));
    然后求出对应两个扇形的面积:s1,s2  依据: s=1/2*g*r*r;
     最后:  s=s1+s2-sm;
    代码:
 #include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
using namespace std; struct circle
{
double x,y,r;
};
double dist(circle a,circle b)
{
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}
int main()
{
circle a,b;
double d,p,area,sb,sa;
while(scanf("%lf%lf%lf%lf%lf%lf",&a.x,&a.y,&a.r,&b.x,&b.y,&b.r)!=EOF)
{
d=dist(a,b);
double rr=min(a.r,b.r);
if(d<=abs(a.r-b.r)) //内含或者内切
area=acos(-1.0)*rr*rr;
else
if(d>=a.r+b.r)
area=0.0;
else{
p=(a.r+b.r+d)/2.0;
sa=acos((a.r*a.r+d*d-b.r*b.r)/(2.0*a.r*d));
sb=acos((b.r*b.r+d*d-a.r*a.r)/(2.0*b.r*d));
area=sa*a.r*a.r+sb*b.r*b.r-*sqrt(p*(p-a.r)*(p-b.r)*(p-d));
}
printf("%.3lf\n",area);
}
return ;
}

hdu---(Tell me the area)(几何/三角形面积以及圆面积的一些知识)的更多相关文章

  1. hdu 4709:Herding(叉积求三角形面积+枚举)

    Herding Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Sub ...

  2. Leetcode812.Largest Triangle Area最大三角形面积

    给定包含多个点的集合,从其中取三个点组成三角形,返回能组成的最大三角形的面积. 示例: 输入: points = [[0,0],[0,1],[1,0],[0,2],[2,0]] 输出: 2 解释: 这 ...

  3. Maximal Area Quadrilateral CodeForces - 340B || 三点坐标求三角形面积

    Maximal Area Quadrilateral CodeForces - 340B 三点坐标求三角形面积(可以带正负,表示向量/点的不同相对位置): http://www.cnblogs.com ...

  4. 【BZOJ1845】[Cqoi2005] 三角形面积并 几何+扫描线

    [BZOJ1845][Cqoi2005] 三角形面积并 Description 给出n个三角形,求它们并的面积. Input 第一行为n(N < = 100), 即三角形的个数 以下n行,每行6 ...

  5. (hdu step 7.1.6)最大三角形(凸包的应用——在n个点中找到3个点,它们所形成的三角形面积最大)

    题目: 最大三角形 Time Limit: 5000/2000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Sub ...

  6. ytu 1058: 三角形面积(带参的宏 练习)

    1058: 三角形面积 Time Limit: 1 Sec  Memory Limit: 128 MBSubmit: 190  Solved: 128[Submit][Status][Web Boar ...

  7. UVa 11437:Triangle Fun(计算几何综合应用,求直线交点,向量运算,求三角形面积)

    Problem ATriangle Fun Input: Standard Input Output: Standard Output In the picture below you can see ...

  8. TZOJ 2519 Regetni(N个点求三角形面积为整数总数)

    描述 Background Hello Earthling. We're from the planet Regetni and need your help to make lots of mone ...

  9. hdu 2034 改革春风吹满地 多边形面积

    改革春风吹满地 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Problem ...

随机推荐

  1. CodeForces 152C Pocket Book

    Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u Submit Status Prac ...

  2. Apply Root Motion

    Apply Root Motion 应用根动作: Should we control the character's position from the animation itself or fro ...

  3. Django1.9 Python3.4出现Error loading MySQLdb

    linux Errorloading MySQLdb module: No module named MySQLdb 这是因为目前 MySQLdb 还不支持 python3.x ,开源无人维护哈 之前 ...

  4. [HRBUST1472]Coin(dp,计数)

    题目链接:http://acm-software.hrbust.edu.cn/problem.php?id=1472 题意:给n个硬币,面值随意.问恰好凑成m元的种类数(去掉重复). dp(i,j,k ...

  5. vsftpd配置参数详细整理

    vsftpd配置参数详细整理  -|白王斧三又干一 vsftpd配置参数详细整理     -|白王斧三又干一 发表于 2005-10-23 20:30:00   1.vsftpd配置参数详细整理#接受 ...

  6. 8.Methods(一)

    1.Instance Constructors and Classes (Reference Types) Constructors methods : 1.allow an instance of ...

  7. Codeforces Round #272 (Div. 2) C. Dreamoon and Sums 数学

    C. Dreamoon and Sums time limit per test 1.5 seconds memory limit per test 256 megabytes input stand ...

  8. HDU-4507 吉哥系列故事——恨7不成妻 数位DP

    题意:给定区间[L, R]求区间内与7无关数的平方和.一个数当满足三个规则之一则认为与7有关:1.整数中某一位是7:2.整数的每一位加起来的和是7的整数倍:3.这个整数是7的整数倍: 分析:初看起来确 ...

  9. 访问远程mysql数据库

    使用mysql命令窗口模式/工具,比如需要给'10.2.9.239' 的用户分配mantis123,mantis123访问,则使用如下格式: GRANT ALL PRIVILEGES ON *.* T ...

  10. c point

    a[i] 与 *(a+i) 是等价的. 事实上在计算a[i]的值时,c语言首先将前者转换为后者形式, 而且,通常而言,用指针编写的程序要比用数组下标编写的程序执行速度快,(为什么?) 因此,应该尽量用 ...