您的位置:首页 > 其它

HDU - 3756 - Dome of Circus

2013-08-11 21:53 387 查看
先上题目

Dome of Circus

Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 931 Accepted Submission(s): 417
Special Judge


[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.

#include <stdio.h>
#include <string.h>
#include <math.h>
#define max(x,y) (x > y ? x : y)
#define MAX 10000+10
const double eps=1e-7;
using namespace std;

typedef struct
{
double x,y,z;
double r;
}point;

point p[MAX];

int n;

double ansv(double r)
{
int i;
double h,tmp;
h=0;
for(i=0;i<n;i++)
{
tmp=p[i].z*r/(r-p[i].r);
h=max(tmp,h);
}
return h;
}

void trisearch()
{
double L,R,mid,midl,midr,h;
L=0;
R=1000000.0;
while(R-L>=eps)
{
mid=(L+R)/2;
midl=(L+mid)/2;
midr=(mid+R)/2;
double hl=ansv(mid);
double hr=ansv(midr);
if(hl*mid*mid<hr*midr*midr) R=midr;
else L=midl;
}
h=ansv(R);
printf("%.3lf %.3lf\n",h,R);
}

int main()
{
int i,t;
//freopen("data.txt","r",stdin);
scanf("%d",&t);
while(t--)
{
scanf("%d",&n);
for(i=0;i<n;i++)
{
scanf("%lf %lf %lf",&p[i].x,&p[i].y,&p[i].z);
p[i].r=sqrt(p[i].x*p[i].x+p[i].y*p[i].y);
}
trisearch();
}
return 0;
}


3756
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: