UVA10573 Geometry Paradox【计算几何】
In the picture below you can see two small circles touching each other. The larger circle touches both of them. The length of the common tangent inscribed inside the larger circle is t and the radiuses of the two smaller circles are r1 and r2. The centers of the three circles are collinear. You will be given the value of r1 and r2 or the value of t. You will have to find the area that is within the larger circle but out of the two smaller circles (marked gray in the picture). If the given data is not enough to find the gray area, print the line ‘Impossible.’ in a single line
Input
First line of the input file contains an integer N (N ≤ 100) which denotes how many sets of inputs are there. Each of the next N lines contain a set of input.
Each set either contains one or two integer. If it contains one integer then it is the value of t, otherwise the two values are the values of r1 and r2. All these integers are less than 100
Output
For each line of input produce one line of output. This line contains the area of the gray part if the given information is enough to find the area of the gray part. Otherwise it contains the line ‘Impossible’. The area should have four digits after the decimal point. Assume that π = 2 ∗ cos−1(0).
Sample Input
2
10 10
15 20
Sample Output
628.3185
1884.9556
问题链接:UVA10573 Geometry Paradox
问题简述:两个相切的小圆r1,r2,同时外切于一个大圆R。已知两小圆的半径分别为r1和r2,给定被大圆截取的两个小圆共同的切线段长度为t,求大圆面积减去两小圆面积为多少。
问题分析:
分析如下:
大圆半径R = r1 + r2
t×t = 4(RR-(r2-r1)^2)= 4r1r2
得:
S = π(RR - r1r1 - r2r2)= π 2r1r2 = π t*t / 8。
需要注意数据输入格式。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* UVA10573 Geometry Paradox */
#include <bits/stdc++.h>
using namespace std;
const double PI = 2 * acos(0.0);
int main()
{
int n;
string s;
double r1, r2;
scanf("%d", &n);
getline(cin, s);
while(n--) {
getline(cin , s);
if(sscanf(s.c_str(), "%lf%lf", &r1, &r2) == 1) {
if(r1 >= 0) printf("%.4f\n", PI * r1 * r1 * 0.125);
else printf("Impossible.\n");
} else {
if (r1 >= 0 && r2 >= 0) printf("%.4f\n", PI * r1 * r2 * 2.0);
else printf("Impossible.\n");
}
}
return 0;
}
上一篇: The Doors POJ - 1556
下一篇: JavaScript倒计时
推荐阅读
-
【计算几何+判断线段是否相交】HDU-1086 You can Solve a Geometry Problem too
-
Geometry Problem HDU - 6242 (随机化+计算几何)
-
计算几何模板+[Uva12304] 2D Geometry 110 in 1
-
UVA - 12304(B - 2D Geometry 110 in 1!)计算几何板子
-
【UVa 12304】2D Geometry 110 in 1! (计算几何、圆)
-
计算几何学 | 线段相交问题 | 平面扫描 | Segment Intersections: Manhattan Geometry | C/C++实现 | 曼哈顿几何
-
UVA10573 Geometry Paradox【计算几何】