http://acm.hdu.edu.cn/showproblem.php?pid=1798

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

代码:

#include <bits/stdc++.h>
using namespace std; int main() {
double x1, y1, r1, x2, y2, r2, minr, maxr, d, ans;
while(~scanf("%lf%lf%lf", &x1, &y1, &r1)) {
scanf("%lf%lf%lf", &x2, &y2, &r2);
d = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
minr = min(r1, r2);
maxr = max(r1, r2);
if(d <= maxr - minr)
ans = acos(-1.0) * minr * minr;
else if(d >= r1 + r2)
ans = 0;
else {
double a1, a2;
double p;
p = (r1 + r2 + d) / 2;
a1 = acos((r1 * r1 + d * d - r2 * r2) / (2 * r1 * d));
a2 = acos((r2 * r2 + d * d - r1 * r1) / (2 * r2 * d));
ans = a1 * r1 * r1 + a2 * r2 * r2 - 2 * sqrt(p * (p - r1) * (p - r2) * (p - d));
}
printf("%.3f\n", ans);
}
return 0;
}

  

HDU 1798 Tell me the area的更多相关文章

  1. HDU 1798 Tell me the area (数学)

    题目链接 Problem Description     There are two circles in the plane (shown in the below picture), there ...

  2. NOIP模拟赛10

    T1 [HAOI2010]软件安装 https://daniu.luogu.org/problem/show?pid=2515 树上背包,如果有i必须有j,j作为i的父节点 O(nm²) #inclu ...

  3. hdu 2528 Area

    2014-07-30 http://acm.hdu.edu.cn/showproblem.php?pid=2528解题思路: 求多边形被一条直线分成两部分的面积分别是多少.因为题目给的直线一定能把多边 ...

  4. hdu 2892 Area

    http://acm.hdu.edu.cn/showproblem.php?pid=2892 解题思路: 求多边形与圆的相交的面积是多少. 以圆心为顶点,将多边形划分为n个三角形. 接下来就求出每个三 ...

  5. hdu 4946 Area of Mushroom(凸包)

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 Area of Mushroom Time Limit: 2000/1000 MS (Java/Ot ...

  6. HDU 1071 The area(求三个点确定的抛物线的面积,其中一个点是顶点)

    传送门: http://acm.hdu.edu.cn/showproblem.php?pid=1071 The area Time Limit: 2000/1000 MS (Java/Others)  ...

  7. HDU 4946 Area of Mushroom(构造凸包)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4946 题目大意:在一个平面上有n个点p1,p2,p3,p4....pn,每个点可以以v的速度在平面上移 ...

  8. HDU 4946 Area of Mushroom 凸包

    链接:pid=4946">http://acm.hdu.edu.cn/showproblem.php?pid=4946 题意:有n个人.在位置(xi,yi),速度是vi,假设对于某个点 ...

  9. HDU 4946 Area of Mushroom 凸包 第八次多校

    题目链接:hdu 4946 题意:一大神有N个学生,各个都是小神,大神有个二次元空间,每一个小神都有一个初始坐标,如今大神把这些空间分给徒弟们,规则是假设这个地方有一个人比谁都先到这,那么这个地方就是 ...

随机推荐

  1. 实践笔记-VA05 销售订单清单 增加字段

    现在都自开发很多报表 ,估计没有多少人 用  VA05 1.在结构 VBMTVZ 中增加需要的字段 2.表t180a 中  添加一条 “添加字段”的数据,如下: 3.取值 修改程序 INCLUDE V ...

  2. 快速玩转linux(3)

    Linux常用命令 软件操作命令 执行操作 命令 软件包管理器 yum 安装软件 yum install xxx 卸载软件 yum remove xxx 搜索软件 yum search xxx 清除缓 ...

  3. 微信小程序播放视频

    <view class="section tc"> <video id="myVideo" src="http://wxsnsdy. ...

  4. flask 中访问时后台错误 error: [Errno 32] Broken pipe

    解决办法:app.run(threaded=True) 个人理解:flask默认单线程,访问一个页面时会访问到很多页面,比如一些图片,加入参数使其为多线程

  5. 预防跨站脚本(xss)

    对xss的防护方法结合在两点上输入和输出,一是严格控制用户表单的输入,验证所有输入数据,有效监测到攻击,go web表单中涉及到.二是对所有输出的数据进行处理,防止已成功注入的脚本在浏览器端运行. 在 ...

  6. Android面试收集录 文件存储

    1.请描述Android SDK支持哪些文件存储技术? 使用SharePreferences保存key-value类型的数据 流文件存储(openFileOutput+openFileInput或Fi ...

  7. Python正则表达式中的re.S,re.M,re.I的作用

    正则表达式可以包含一些可选标志修饰符来控制匹配的模式.修饰符被指定为一个可选的标志.多个标志可以通过按位 OR(|) 它们来指定.如 re.I | re.M 被设置成 I 和 M 标志: 修饰符 描述 ...

  8. vue2018年5月报错No parser and no file path given

    mac电脑直接: rm -rf node_modules rm package-lock.json npm install npm install prettier@~1.12.1 执行完这四个命令, ...

  9. c/c++容器操作

    C++中的容器大致可以分为两个大类:顺序容器和关联容器.顺序容器中包含有顺序容器适配器. 顺序容器:将单一类型元素聚集起来成为容器,然后根据位置来存储和访问这些元素.主要有vector.list.de ...

  10. c/c++ 随机数生成

    当程序需要一个随机数时有两种情况下使用: 1.程序中只需使用一次随机数,则调用rand()函数即可 2.程序需要多次使用随机数,那么需要使用srand()函数生成随机数种子在调用rand()函数保证每 ...