hdu 1798 - Tell me the area(求两圆相交面积) 解题报告
来源:互联网 发布:西瓜影音播放器mac版 编辑:程序博客网 时间:2024/05/19 13:29
Tell me the area
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 2113 Accepted Submission(s): 642
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
#include<stdio.h>#include<math.h>#define PI acos(-1.0)int main(){ double a1,b1,r1,a2,b2,r2,d; double A1,A2,s1,s2,s; while(~scanf("%lf%lf%lf%lf%lf%lf",&a1,&b1,&r1,&a2,&b2,&r2)) { d=sqrt((a2-a1)*(a2-a1)+(b2-b1)*(b2-b1)); //求圆心距 if(d>=r1+r2) printf("0.000\n"); //两圆相离或相外切 else if(d<=fabs(r1-r2))//内切或内含 { if(r1>r2) printf("%0.3lf\n",PI*r2*r2); else printf("%0.3lf\n",PI*r1*r1); } else{ A1=2*acos((d*d+r1*r1-r2*r2)/(2*d*r1)); //用余弦定理求以圆心为顶点与两圆交点连线的角 A2=2*acos((d*d+r2*r2-r1*r1)/(2*d*r2)); s1=0.5*r1*r1*sin(A1)+0.5*r2*r2*sin(A2); s2=A1/2*r1*r1+A2/2*r2*r2; s=s2-s1; printf("%0.3lf\n",s); } }}
0 0
- hdu 1798 - Tell me the area(求两圆相交面积) 解题报告
- HDU 1798 Tell me the area (两圆相交面积)
- Tell me the area(计算几何--求两圆相交面积)
- HDU 1798 Tell me the area(计算几何,求相交圆面积)
- hdu 1798 Tell me the area(相交圆的面积)
- HDU-1798 Tell me the area (C++和Java【水】两圆相交求公共面积)
- HDU1798 Tell me the area(两圆的相交面积)
- HDU 1798 Tell me the area
- HDU 1798 Tell me the area
- hdu 1798 Tell me the area
- HDU 1798 Tell me the area
- Tell me the area HDU 1798
- HDU-1798 Tell me the area(数学)
- hdoj1798Tell me the area【求两圆相交部分的面积】
- hdu 1098 Tell me the area
- Tell me the area
- Tell me the area
- HDOJ 题目1798 Tell me the area
- 调试Makefile变量
- tcp三次握手的过程,accept发生在三次握手哪个阶段?
- hdu 动态规划学习目标
- VIM使用(保持更新)
- 基于.NET实现淘宝发布宝贝功能(三)
- hdu 1798 - Tell me the area(求两圆相交面积) 解题报告
- 配置php生产环境——notice warning消除
- objective-c类以及方法调用的基本总结
- HDOJ 1551 Cable master(二分)
- 21. 包含min函数的栈
- Andrew Ng Machine Learning 专题【Logistic Regression & Regularization】
- RMQ算法 快速求区间最大最小值
- 自动布局Cell
- 线段覆盖长度