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. ABAP术语-Fiscal Year

    Fiscal Year 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/02/1062109.html Generally a period ...

  2. This system is registered to Red Hat Subscription Management, but is not receiving updates. You can use subscription-manager to assign subscriptions.

    Wrong date and time, reset the date and time in the system properly. It may also happen that system ...

  3. ELK初学搭建

    目录:基础准备 修改相关系统配置 安装elasticsearch 安装 kibana 安装logstash X-pack插件的安装 登录网页查看 ELK名字解释 ELK就是ElasticSearch ...

  4. SI - 系统 - 操作系统简述 (Operating System)

    Unix 操作系统:System V.BSD Microsoft Windows Apple Mac OS Linux FreeBSD 安装 https://jingyan.baidu.com/art ...

  5. jqGrid使用手册

    JQGrid是一个在jquery基础上做的一个表格控件,以ajax的方式和服务器端通信. JQGrid Demo 是一个在线的演示项目.在这里,可以知道jqgrid可以做什么事情.jQgrid 使用详 ...

  6. android 自定义滑动按钮

    第一接触公司项目就让我画页面,而且还涉及到我最讨厌的自定义view  但是没办法,讨厌也必须要做啊,经过百度上资源的查找,终于写出了一个滑动控件.废话不多说,上代码. package com.eton ...

  7. collections模块的使用

    1. Counter counter是collections中的一个模块, 它能够统计出字符串/文本中的每一个元素出现的次数, 并可以对结果进行进一步的处理. 使用方法 传入: 字符串 默认返回: C ...

  8. Educational Codeforces Round 47 (Rated for Div. 2) :C. Annoying Present(等差求和)

    题目链接:http://codeforces.com/contest/1009/problem/C 解题心得: 题意就是一个初始全为0长度为n的数列,m此操作,每次给你两个数x.d,你需要在数列中选一 ...

  9. react ant-design自定义图标

    ant-design给我们提供的图标不够怎么办呢?答案是我们可以自定义图标. 自定义图标也挺简单的,现在图标推荐用svg格式,那么我们就需要制作svg图片. 下面让我们看看如果制作svg图片吧. 1. ...

  10. 【转】谈谈 iOS 中图片的解压缩

    转自:http://blog.leichunfeng.com/blog/2017/02/20/talking-about-the-decompression-of-the-image-in-ios/ ...