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. [POJ1753]Flip Game(异或方程组,高斯消元,枚举自由变量)

    题目链接:http://poj.org/problem?id=1753 题意:同上. 这回翻来翻去要考虑自由变元了,假设返回了自由变元数量,则需要枚举自由变元. /* ━━━━━┒ギリギリ♂ eye! ...

  2. Servlet&jsp基础:第四部分

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

  3. [Java解惑]类

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

  4. CUBRID学习笔记 13 日志文件

    欢迎转载 ,转载时请保留作者信息.本文版权归本人所有,如有任何问题,请与我联系wang2650@sohu.com . 过错 CUBRID Broker Log Files  可以理解为数据库中间件日志 ...

  5. Codeforces Round #249 (Div. 2) A题

    链接:http://codeforces.com/contest/435/problem/A   A. Queue on Bus Stop time limit per test 1 second m ...

  6. 2.mybatis入门实例 连接数据库进行查询

    1.新建项目,添加mybatis和mysql的jar包 2.在mysql中新建表user[id,name,age] CREATE TABLE `users` ( `id` ) NOT NULL aut ...

  7. 如何在VirtualBox虚拟机软件上安装Win7虚拟系统

    在Windows系统中安装VirtualBox 双击从官网上下载的VirtualBox-4.3.12-93733-Win.exe安装程序,默认下一步,下一步完成基础安装. 在VirtualBox虚拟机 ...

  8. 强制性签出被人没有签入的文件(在.net开发vs中)

    灵感,是天才的女神.她并不步履蹒跚地走过,而是在空中像乌鸦那么警觉地飞过的,她没有什么剽带给诗人抓握,她的头是一团烈火,她溜得快,像那些白里带红的鹤,教猎人见了无可奈何.——巴尔扎克(上海网站建设) ...

  9. iOS - UIWindow

    前言 NS_CLASS_AVAILABLE_IOS(2_0) @interface UIWindow : UIView @available(iOS 2.0, *) public class UIWi ...

  10. poj1319Pipe Fitters

    链接 算不上几何的水题 第一种为(int)a*(int)b: 第二种分宽高交换两种讨论. 每一个的高度除第一个为1外其它的都可以看着b/sqrt(3.0)/2; #include <iostre ...