Tell me the area(计算几何--求两圆相交面积)
来源:互联网 发布:python数据分析 pdf 编辑:程序博客网 时间:2024/05/21 17:53
Problem Link:http://acm.hdu.edu.cn/showproblem.php?pid=1798
Tell me the area
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2828 Accepted Submission(s): 903
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 22 2 1
Sample Output
0.108
Author
wangye
Source
2008 “Insigma International Cup” Zhejiang Collegiate Programming Contest - Warm Up(4)
AC code:
#include<stdio.h>#include<math.h>#include<string.h>#include<algorithm>#define PI acos(-1)using namespace std;int main(){int T;double r1,r2,x1,x2,y1,y2,dr,r,A1,A2,p,s,s1,s2,ans;while(scanf("%lf%lf%lf",&x1,&y1,&r1)!=EOF){scanf("%lf%lf%lf",&x2,&y2,&r2);dr=sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));r=min(r1,r2);if(dr>=r1+r2)printf("0.000\n");else if(dr<=fabs(r1-r2) && dr>=0){ans=PI*r*r;printf("%0.3lf\n",ans);}else{A1=acos((r1*r1+dr*dr-r2*r2)/(2*r1*dr));A2=acos((r2*r2+dr*dr-r1*r1)/(2*r2*dr));p=(r1+r2+dr)/2;s=sqrt(p*(p-r1)*(p-r2)*(p-dr));s1=s-PI*r2*r2*(A2/(2*PI));s2=s-PI*r1*r1*(A1/(2*PI));ans=2*(s-s1-s2);printf("%.3lf\n",ans);}}return 0;}
1 0
- Tell me the area(计算几何--求两圆相交面积)
- HDU 1798 Tell me the area(计算几何,求相交圆面积)
- hdu 1798 - Tell me the area(求两圆相交面积) 解题报告
- HDU 1798 Tell me the area (两圆相交面积)
- HDU1798 Tell me the area(两圆的相交面积)
- Tell me the area 几何
- hdu 1798 Tell me the area(相交圆的面积)
- HDU-1798 Tell me the area (C++和Java【水】两圆相交求公共面积)
- hdoj1798Tell me the area【求两圆相交部分的面积】
- Tell me the area
- Tell me the area
- POJ 2546 Circular Area [相交园面积]【计算几何】
- POJ 2546 Circular Area(计算几何 两圆相交面积)
- HDU-1798 Tell me the area(数学)
- ACM--两圆交集的面积--HDOJ 1798--Tell me the area
- HDU 1798 Tell me the area
- hdu 1098 Tell me the area
- HDU 1798 Tell me the area
- 求解两个数组中总体平均的差的绝对值和最小
- C/C++ 打印格式小结
- Struts中Action动态使用
- 搜索二叉树的后序遍历判断
- 结对编程四则运算
- Tell me the area(计算几何--求两圆相交面积)
- 大话设计模式读书笔记(四) 装饰模式
- ZOJ
- cocos2d-x 提升篇 (17) 简单的桌上足球游戏
- shell中各种括号的作用()、(())、[]、[[]]、{}
- linux系统中从网络自动获取软件及更新的工具
- kubernetes源码阅读之controller-manager(二)
- JVM之GC详解
- Lintcode 二叉查找树中搜索区间