hdu 3756 三分 Dome of Circus
2012-09-15 10:59
337 查看
题意:
给你很多个点,让你输出一个r和h,使这样的圆锥体能覆盖给出的所有点并且体积最小。
题解:
三分(因为是个最值的问题)。枚举r,得到h。
做题过程:
wa了一两次。刚开始是因为只输出2位小数,而题目的要求是输出3位小数。后来就再也找不到错误了。 最后,在今天,将三分的上限改了一改,就A了。。。只能说,我还too young ,too simple啊。。。
给你很多个点,让你输出一个r和h,使这样的圆锥体能覆盖给出的所有点并且体积最小。
题解:
三分(因为是个最值的问题)。枚举r,得到h。
做题过程:
wa了一两次。刚开始是因为只输出2位小数,而题目的要求是输出3位小数。后来就再也找不到错误了。 最后,在今天,将三分的上限改了一改,就A了。。。只能说,我还too young ,too simple啊。。。
/* Pro: 0 Sol: date: */ #include <iostream> #include <cstdio> #include <algorithm> #include <cstring> #include <cmath> #include <queue> #define eps 1e-7 #include <set> #include <vector> using namespace std; struct point{ double x,y,z; point(){} point(double a, double b, double c){x = a, y = b, z = c;} }p[11111]; int n,T; double a,b,c; double cal(double r){ double h ,Max = 0; for(int i = 0; i < n; i ++){ h = p[i].z * r / (r - sqrt(p[i].x * p[i].x + p[i].y * p[i].y)); Max = max(h,Max); } return r * r * Max; } void thi(double &r, double &h){ double low = 0.0, high = 10000; double m1,m2; while(low + eps < high){ m1 = (low + high) / 2.0; m2 = (m1 + high) / 2.0; if(cal(m1) <= cal(m2)) high = m2; else { low = m1; } } r = low; h = -1; for(int i = 0; i < n; i ++){ h = max(h,p[i].z * r / (r - sqrt(p[i].x * p[i].x + p[i].y * p[i].y)) ); } } int main(){ scanf("%d",&T); while(T --){ scanf("%d",&n); for(int i = 0; i < n; i ++){ scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z); } double r,h; thi(r,h); printf("%.3f %.3f\n",h,r); } return 0; }
相关文章推荐
- HDU 3756 Dome of Circus
- HDU 3756,LA 4986——Dome of Circus
- hdu Dome of Circus
- HDU 3756 Dome of Circus(计算几何 + 三分)
- HDU 3756 Dome of Circus 三分
- hdu 3756 || Dome of Circus || 2010 Northeastern European Regional Contest(三分)
- hdu 3756 Dome of Circus(三分)
- HDU Dome of Circus
- hdu 3756 Dome of Circus 三分
- HDU 3756 Dome of Circus 三分
- 【凸包】【三分】Gym - 101309D - Dome of Circus
- HDU 3756 Dome of Circus (三分)
- hdu 3756 Dome of Circus 三分
- hdoj 3756 Dome of Circus(三分)
- hdu 3756 Dome of Circus(模拟退火)
- HDU 3756 三分
- HDU 5514 Game of Flying Circus
- HDU 3756 Dome of Circus
- UVA1473 - Dome of Circus
- uva 1473 - Dome of Circus