Tell me the area HDU 1798
2017-07-26 15:13
483 查看
Tell me the area
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2958 Accepted Submission(s): 946
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
[分析]
数学题。
首先判断相离相交还是包含(是叫包含吗?有点忘记了)。
相离就0.00,包含就输出小圆的面积。
相交先算出角A和角B的角度,算出2个扇形面积,减去两个三角形面积。
最后有注释。
[代码]
[注释1]首先使用余弦定理算出角A
不过因为cd不知道长度所以只好改算角cab。最后乘2就是角A的大小了。
[注释2]三角形面积公式1/2*a*b*sin(c);
[注释3]扇形面积公式1/2*r*r*a;
Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 2958 Accepted Submission(s): 946
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
[分析]
数学题。
首先判断相离相交还是包含(是叫包含吗?有点忘记了)。
相离就0.00,包含就输出小圆的面积。
相交先算出角A和角B的角度,算出2个扇形面积,减去两个三角形面积。
最后有注释。
[代码]
#include<cstdio> #include<cmath> #define PI acos(-1) int main() { double x1, y1, r1; double x2, y2, r2; while (scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &r1, &x2, &y2, &r2) != EOF) { double dis = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2)); if (dis >= r1 + r2)printf("0.000\n");//相离 else if (dis <= fabs(r1 - r2))//包含 { if (r1 > r2)printf("%.3lf\n", PI*r2*r2); else printf("%.3lf\n", PI*r1*r1); } else//相交 { double a1 = 2 * acos((dis*dis + r1*r1 - r2*r2) / (2 * dis*r1));//注释1 double a2 = 2 * acos((dis*dis + r2*r2 - r1*r1) / (2 * dis*r2)); double sanjiao = 0.5*r1*r1*sin(a1) + 0.5*r2*r2*sin(a2);//注释2 double ans = 0.5*r1*r1*a1 + 0.5*r2*r2*a2 - sanjiao;//注释3 printf("%.3lf\n", ans); } } }
[注释1]首先使用余弦定理算出角A
不过因为cd不知道长度所以只好改算角cab。最后乘2就是角A的大小了。
[注释2]三角形面积公式1/2*a*b*sin(c);
[注释3]扇形面积公式1/2*r*r*a;
相关文章推荐
- HDU 1798 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 …
- HDU 1798 Tell me the area(计算几何,求相交圆面积)
- HDU 1798 Tell me the area
- HDU-1798 Tell me the area (C++和Java【水】两圆相交求公共面积)
- hdu 1798 Tell me the area
- HDU 1798 Tell me the area (计算几何)
- hdu 1798 Tell me the area(相交圆的面积)
- hdu---(Tell me the area)(几何/三角形面积以及圆面积的一些知识)
- HDOJ 题目1798 Tell me the area
- ACM--两圆交集的面积--HDOJ 1798--Tell me the area
- Tell me the area---hdu1798 (数学 几何)
- HDU1798 Tell me the area(两圆的相交面积)
- hdu 1798 - Tell me the area(求两圆相交面积) 解题报告
- Tell me the area(计算几何--求两圆相交面积)
- Tell me the area
- Tell me the area 几何