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. (转)Genymotion安装virtual device的“unable to create virtual device, Server returned Http status code 0”的解决方法

    网络原因无法下载virtual device,status 为0表示服务器没有响应.FQ下载吧,有VPN的小伙伴推荐这种. 或者直接手动下载ova虚拟机文件,然后将虚拟机文件导入到virtualbox ...

  2. jquery选择器 :first与:first-child区别

    一个例子: <ul>  <li>John</li>  <li>Karl</li>  <li>Brandon</li> ...

  3. 模块mod_h323的编译

    去h.323plus官网上下载关联的库 http://www.h323plus.org/source/ 很贴心,分操作系统下载,而且关联的ptlib库的版本也一并列了出来. 一.编译ptlib库 ex ...

  4. 精通正则表达式(第三版)——Mastering Regular Expressions,3rd Edition——读书笔记1

    基础知识介绍: 子表达式匹配 环视 引号内的字符串:"(^")*" 12小时制:(1[0123]|[1-9]):[0-5][0-9]*(am|pm) 24小时制:(([0 ...

  5. [SAP ABAP开发技术总结]ABAP常用事务码

    声明:原创作品,转载时请注明文章来自SAP师太技术博客( 博/客/园www.cnblogs.com):www.cnblogs.com/jiangzhengjun,并以超链接形式标明文章原始出处,否则将 ...

  6. python_way day18 html-day4, Django路由,(正则匹配页码,包含自开发分页功能), 模板, Model(jDango-ORM) : SQLite,数据库时间字段插入的方法

    python_way day18 html-day4 1.Django-路由系统   - 自开发分页功能 2.模板语言:之母板的使用 3.SQLite:model(jDango-ORM) 数据库时间字 ...

  7. HTML笔记(四) 框架

    通过框架,可以在一个窗口显示多个页面.而所谓的框架,就是指每一份HTML文档. 框架结构标签<frameset> 定义如何将窗口分割为框架. frameset定义了一系列的行列. rows ...

  8. RedHat安装DB2详细步骤(附卸载、备份恢复步骤)

    1.创建用户组和用户 说明: 步骤1 以root用户登录需要安装DB2的服务器. 步骤2 创建用户组和用户. # su -root # groupdel db2grp # groupdel db2fg ...

  9. Eclipse 高亮显示选中的相同变量

    问题描述: 在 eclipse 中使用快捷键或其他原因,不小心按错了,使得变量的高亮显示没了. 1.网友解决方法:  选择:windows-> preferences->java-> ...

  10. iOS - OC NSKeyedArchiver 数据归档

    前言 @interface NSKeyedArchiver : NSCoder @interface NSKeyedUnarchiver : NSCoder 在 OC 语言中,归档是一个过程,即用某种 ...