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. 不再手写import - VSCode自动引入Vue组件和Js模块

    :first-child{margin-top:0!important}.markdown-body>:last-child{margin-bottom:0!important}.markdow ...

  2. [HAOI2007]理想的正方形(随机化,骗分?)

    题目描述 有一个a*b的整数组成的矩阵,现请你从中找出一个n*n的正方形区域,使得该区域所有数中的最大值和最小值的差最小. 输入输出格式 输入格式: 第一行为3个整数,分别表示a,b,n的值 第二行至 ...

  3. ABAP术语-Lock Object

    Lock Object 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/29/1085742.html Object type in the ...

  4. ABAP术语-IDOC

    IDOC 原文:http://www.cnblogs.com/qiangsheng/archive/2008/02/21/1075988.html Intermediate Document Inte ...

  5. flutter开发之配置环境以及一些问题的处理方案~

        今天flutter1.0已经发布了,有没有一点小小的兴奋,为了纪念这个令人激动的日子,我决定发一篇flutter的基本环境搭建的教程送给大家:) 由于这是一篇关于flutter配置环境的教程, ...

  6. jquery 节点

    $("ul li:eq(3)")  // 元素的index位置工0开始计数,所以这里的3实际为第4个元素 $("ul").find("li" ...

  7. PHP中判断变量为空的几种方法小结

    isset  主要用来判断变量是否被初始化过empty  可以将值为 "假"."空"."0"."NULL"." ...

  8. Python基本数据类型(二)

    数字类型: 数字的定义: 1.数字不可变,不可迭代 在python3里面所有的整形都是  int 在python2里面数字叫整型,整数类型,有int 有long 数字的方法: 数字的方法: 1.--- ...

  9. golang 三个点的用法

    已经忘了这是第几次查这个用法了,还是记一下吧~ ^ _ ^ 本文同时发表在https://github.com/zhangyachen/zhangyachen.github.io/issues/137 ...

  10. Kubernetes-深入分析集群安全机制(3.6)

    集群的安全性主要考虑以下几个方面: 容器与所在宿主机的隔离: 限制容器给基础设施及其他容器带来消极影响的能力: 最小权限原则--合理限制所有组件的权限,确保组件只执行它被授权的行为,通过限制单个组件的 ...