题目链接

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

分析:

两圆的位置关系有相离、相切和相交三种,相切又有外切和内切。

如果两圆的位置关系是相离或者外切的话,它们是没有公共部分的,及面积为0;

如果两圆内切,公共部分就为整个的小圆,面积也就是小圆的面积;

如果两圆相交的话,面积就应该是每个圆所对应的扇形减去所对应的三角形的面积和。

代码:

#include<stdio.h>
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
double q,w,m,n,a,b,c,x,y,z,PI;
PI=2*asin(1.0);
while(~scanf("%lf%lf%lf",&a,&b,&c))
{
scanf("%lf%lf%lf",&x,&y,&z);
a=sqrt((a-x)*(a-x)+(b-y)*(b-y));///计算圆心距
///如果两圆相离、外切或至少一圆半径为0时,那么所求面积为0
if(a>=c+z||!c||!z)x=0;
///如果两内切或内含,那么所求面积为小圆面积
else if(a<=fabs(z-c))
{
if(z>c)z=c;
x=z*z*PI;
}
///如果两圆相交,面积求解如下
else
{
///由余弦定理求出公共弦在圆o1中对应的圆心角的一半
b=acos((a*a+c*c-z*z)/(2*a*c));
///由余弦定理求出公共弦在圆o2中对应的圆心角的一半
y=acos((a*a+z*z-c*c)/(2*a*z));
///计算圆o1中扇形面积
m=b*c*c;
///计算圆o2中扇形面积
n=y*z*z;
///计算圆o1中扇形所对应的三角形面积
q=c*c*sin(b)*cos(b);
///计算圆o2中扇形所对应的三角形面积
w=z*z*sin(y)*cos(y);
///q+w为图中四边形面积,两扇形面积之和与四边形面积之差即为
///所求面积。在图2中y为钝角,计算出的面积w为负值,这时q+w
///表示两三角面积之差,刚好还是四边形面积,因此对于图1和图
///2不必分情况讨论
x=m+n-(q+w);
}
printf("%.3f\n",x);
}
return 0;
}

HDU 1798 Tell me the area (数学)的更多相关文章

  1. HDU 1798 Tell me the area

    http://acm.hdu.edu.cn/showproblem.php?pid=1798 Problem Description     There are two circles in the ...

  2. HDU 1071 The area (数学定积分)

    题意:求阴影部分面积. 析:没什么可说的,就是一个普通的定积分. 代码如下: #include <cstdio> #include <iostream> using names ...

  3. HDU 4342——History repeat itself——————【数学规律】

    History repeat itself Time Limit: 1000ms Memory Limit: 32768KB This problem will be judged on HDU. O ...

  4. hdu 1597 find the nth digit (数学)

    find the nth digit Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Other ...

  5. HDU 6659 Acesrc and Good Numbers (数学 思维)

    2019 杭电多校 8 1003 题目链接:HDU 6659 比赛链接:2019 Multi-University Training Contest 8 Problem Description Ace ...

  6. HDU 5019 Revenge of GCD(数学)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5019 Problem Description In mathematics, the greatest ...

  7. HDU 5476 Explore Track of Point 数学平几

    Explore Track of Point Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem ...

  8. hdu 4091 Zombie’s Treasure Chest(数学规律+枚举)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4091 /** 这题的一种思路就是枚举了: 基于这样一个事实:求出lcm = lcm(s1,s2), n ...

  9. HDU 4099 Revenge of Fibonacci (数学+字典数)

    传送门:http://acm.hdu.edu.cn/showproblem.php?pid=4099 这个题目就是一个坑或. 题意:给你不超过40的一串数字,问你这串数字是Fibonacci多少的开头 ...

随机推荐

  1. Can’t delete list item in Sharepoint2013

         Today,I have meet a very strange error.When I attempt to delete a item from a list,I recieve an ...

  2. Git初步

    在多人参与开发的项目中,版本控制工具是必须的,网上有很多不错的教程,能简单使用就ok了,粘几篇教程,方便学习 首先我们要了解一些基本的概念,此处简单描述一下 (1)集中式版本控制系统: CVS.SVN ...

  3. 《python核心编程第二版》第5章习题

    5-1 整形 讲讲 Python 普通整型和长整型的区别 答:普通整型 32位,长整数类型能表达的 数值仅仅与你的机器支持的(虚拟)内存大小有关 5-2 运算符(a) 写一个函数,计算并返回两个数的乘 ...

  4. WOW.js 的使用方法

    WOW.js 是一个非常轻量级的动画效果插件,使用它可以组合多种炫酷的效果. 使用WOW.js可以实现我们在网站上常看到的,页面滚动到指定区域时就显示动画的效果. 1.要使用WOW.js必须引入:WO ...

  5. bzoj1367 可并堆

    题面 参考:<左偏树的特点及运用--黄河源> 我们将这个数列划为很多个互不相交的区间,每一段区间内的 \(b\) 是相等的,即 \(b[l[i]]=b[l[i]+1]=...=b[r[i] ...

  6. linux备忘录-程序管理与SELinux

    知识点 程序与程序(Process and Program) 通过执行一条指令或程序,则可以触发一个事件,并获得一个PID.当我们需要启动一个程序时,我们是启动一个二进制文件(binary file) ...

  7. BZOJ 1565 NOI2009 植物大战僵尸 topo+最小割(最大权闭合子图)

    题目链接:https://www.luogu.org/problemnew/show/P2805(bzoj那个实在是有点小小的辣眼睛...我就把洛谷的丢出来吧...) 题意概述:给出一张有向图,这张有 ...

  8. 【解决】Node JS Error: ENOENT

    The Node Beginner Book 书中的实例代码当上传图片时会报Error: ENOENT, 原因:图片默认会选择系统的缓存文件夹下,在windows下无权访问C盘,所以就报错了.. 解决 ...

  9. 日历插件DatePicker

    Datepicker 地址:https://getuikit.com/v2/docs/datepicker.html

  10. lintcode-51-上一个排列

    51-上一个排列 给定一个整数数组来表示排列,找出其上一个排列. 注意事项 排列中可能包含重复的整数 样例 给出排列[1,3,2,3],其上一个排列是[1,2,3,3] 给出排列[1,2,3,4],其 ...