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. .scripts/mysql_install_db: 没有那个文件或目录

    .scripts/mysql_install_db: 没有那个文件或目录 查了好多地方,在书上找到了解决方案,太不容易了 原因与解决方法: 系统与MYSQL版本不同,系统64位使用64位MYSQL,3 ...

  2. 01-HTML深入

    1.1  浏览器的工作原理 把一些标签解析成用户可视化的页面 1.2 HTML中的标签与元素 在HTML中以<xx>开始,以</xx>结束,比如<html>< ...

  3. phpspider 的简单使用

    phpspider 的简单使用 phpspider是一款PHP开发蜘蛛爬虫框架. 官方github下载地址:https://github.com/owner888/phpspider官方文档下载地址: ...

  4. Python 一些好玩的函数

    一.匿名函数 什么匿名是函数: 不需要使用def函数名的函数或者子程序 函数语法: lambda 参数:表达式 函数特点: 1.lambda只是一个表达式,省去定义函数过程,让代码更精简 2.lamb ...

  5. 在Liunx上搭建FTP并配置用户权限

    伴随着.Net Core的开源,公司前几天上了新的Liunx服务器,我在前几篇文章中介绍了如何搭建环境以及部署.Net Core应用. 然后,今天客户和我说想自己给网站做推广,需要用FTP链接我们的服 ...

  6. 微信小程序图片上传

    uploadImage : function (){ wx.chooseImage({ count: 9, // 默认9 sizeType: ['original', 'compressed'], / ...

  7. css文本截字,超出文本省略号显示

    一.单行文本截字 p { text-overflow: ellipsis;/*显示省略号代替裁剪的文本*/ white-space: nowrap;/*空白处理方式 不换行*/ overflow: h ...

  8. JavaScript Shell学习分享

    目录 JavaScript Shell学习分享 简介 安装 使用原因 小结 JavaScript Shell学习分享 简介 JavaScript Shell是由Mozilla提供的综合JavaScri ...

  9. ffmpeg使用笔记

    1.从mp4中提取h264:ffmpeg -i 264.mp4 -codec copy -bsf h264_mp4toannexb -f h264 output.h2642.从mp4中提取hevc:f ...

  10. 分支push不上去的问题

    还原一下现场,我在自己的项目里面,从master里面checkout的一个分支,当我在我这个分支里面进行 push代码的操作,我突然发现我的代码不能执行push的操作,如图 这个原因是由于远端的仓库没 ...