hdu Dome of Circus
2012-08-31 22:10
211 查看
Dome of Circus |
Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) |
Total Submission(s): 283 Accepted Submission(s): 139 |
[align=left]Problem Description[/align] A travelling circus faces a tough challenge in designing the dome for its performances. The circus has a number of shows that happen above the stage in the air under the dome. Various rigs, supports, and anchors must be installed over the stage, but under the dome. The dome itself must rise above the center of the stage and has a conical shape. The space under the dome must be air-conditioned, so the goal is to design the dome that contains minimal volume. You are given a set of n points in the space; (xi, yi, zi) for 1 ≤ i ≤ n are the coordinates of the points in the air above the stage that must be covered by the dome. The ground is denoted by the plane z = 0, with positive z coordinates going up. The center of the stage is on the ground at the point (0, 0, 0). The tip of the dome must be located at some point with coordinates (0, 0, h) with h > 0. The dome must have a conical shape that touches the ground at the circle with the center in the point (0, 0, 0) and with the radius of r. The dome must contain or touch all the n given points. The dome must have the minimal volume, given the above constraints. |
[align=left]Input[/align] The input begins with an integer T. The next T blocks each represents a case. The first line of each case contains a single integer number n (1 ≤ n ≤ 10 000) - the number of points under the dome. The following n lines describe points with three floating point numbers xi, yi, and zi per line - the coordinates of i-th point. All coordinates do not exceed 1000 by their absolute value and have at most 2 digits after decimal point. All zi are positive. There is at least one point with non-zero xi or yi. |
[align=left]Output[/align] For each case , write to the output file a single line with two floating point numbers h and r - the height and the base radius of the dome. The numbers must be precise up to 3 digits after decimal point. |
[align=left]Sample Input[/align]3 1 1.00 0.00 1.00 2 1.00 0.00 1.00 0.00 1.50 0.50 3 1.00 0.00 1.00 0.00 1.50 0.50 -0.50 -0.50 1.00 |
[align=left]Sample Output[/align]3.000 1.500 2.000 2.000 2.000 2.000 |
[align=left]Author[/align] Georgiy Korneev |
[align=left]Source[/align] 2010 Northeastern European Regional Contest |
[align=left]Recommend[/align] notonlysuccess |
#include<cstdio> #include<cmath> #define eps 1e-6 int n; double x[10010], z[10010]; double fun(double H) { int i; double r = 0; for (i = 0; i < n; ++i) { if (H * x[i] / (H - z[i]) > r) r = H * x[i] / (H - z[i]); } return r; } int main() { double a, b, c, d, t, r1, r2, temp; int T, i; scanf("%d", &T); while (T--) { a = 0; b = 1e9; scanf("%d", &n); for (i = 0; i < n; ++i) { scanf("%lf%lf%lf", &x[i], &t, &z[i]); x[i] = sqrt(x[i] * x[i] + t * t); if (z[i] > a) a = z[i]; } while (b - a > eps) { temp = (b - a) / 3; c = a + temp; d = b - temp; r1 = fun(c); r2 = fun(d); if (r1 * r1 * c < r2 * r2 * d) b = d; else a = c; } printf("%.3f %.3f\n", a, fun(a)); } return 0; }
相关文章推荐
- HDU 3756,LA 4986——Dome of Circus
- hdu 3756 三分 Dome of Circus
- HDU Dome of Circus
- HDU 3756 Dome of Circus
- 【凸包】【三分】Gym - 101309D - Dome of Circus
- UVA1473 - Dome of Circus
- HDU 5514 Game of Flying Circus
- HDU 5515 Game of Flying Circus
- LA4986 Dome of Circus
- uva 1473 - Dome of Circus
- [HDU3756]Dome of Circus
- HDU 2108 Shape of HDU(几何)
- HDU Box of Bricks
- HDU 4898 The Revenge of the Princess’ Knight(后缀数组+二分+暴力)(2014 Multi-University Training Contest 4)
- HDU-5943 Kingdom of Obsession
- HDU 3102 Lawrence of Arabia(dp)
- hdu 1817 Necklace of Beads(Polya定理)
- HDU 5087 Revenge of LIS II
- hdu(4461) The Power of Xiangqi
- HDU 2110-Crisis of HDU(母函数)