Problem Description
Each person had do something foolish along with his or her growth.But,when he or she did this that time,they could not predict that this thing is a mistake and they will want this thing would rather not happened.
The world king Sconbin is not the exception.One day,Sconbin was sleeping,then swakened by one nightmare.It turned out that his love letters to Dufein were made public in his dream.These foolish letters might ruin his throne.Sconbin decided to destroy the letters by the military exercises’s opportunity.The missile is the best weapon.Considered the execution of the missile,Sconbin chose to use one missile with the minimum destruction.
Sconbin had writen N letters to Dufein, she buried these letters on different places.Sconbin got the places by difficult,he wants to know where is the best place launch the missile,and the smallest radius of the burst area. Let’s help Sconbin to get the award.
Input
There are many test cases.Each case consists of a positive integer N(N<500,V,our great king might be a considerate lover) on a line followed by N lines giving the coordinates of N letters.Each coordinates have two numbers,x coordinate and y coordinate.N=0 is the end of the input file.
Output
For each case,there should be a single line in the output,containing three numbers,the first and second are x and y coordinates of the missile to launch,the third is the smallest radius the missile need to destroy all N letters.All output numbers are rounded to the second digit after the decimal point.
Sample Input
3
1.00 1.00
2.00 2.00
3.00 3.00
0
Sample Output
2.00 2.00 1.41
板子
struct Point{
double x,y;
Point(double x=0,double y=0):x(x),y(y){}
bool operator ==(const Point& b){return !sgn(x-b.x)&&!sgn(y-b.y);}
bool operator <(const Point& b)const{return !sgn(x-b.x)?y<b.y:x<b.x;}
double operator^(const Point& b){return x*b.y-y*b.x;}//叉积
double operator*(const Point& b){return x*b.x+y*b.y;}//点积
Point operator +(const Point &b){return Point(x+b.x,y+b.y);}
Point operator -(const Point& b){return Point(x-b.x,y-b.y);}
Point operator *(const double &k){return Point(x*k,y*k);}
Point operator /(const double &k){return Point(x/k,y/k);}
double distance(Point b){return hypot(x-b.x,y-b.y);}
};
struct circle{
Point p;//圆心
double r;//半径
circle(){}
circle(Point p,double r):p(p),r(r){}
circle(Point a,Point b,Point c){//三角形的外接圆//利用两条边的中垂线得到圆心
Line u=Line((a+b)/2,((a+b)/2)+((b-a).rotleft()));
Line v=Line((b+c)/2,((b+c)/2)+((c-b).rotleft()));
p=u.crosspoint(v),r=p.distance(a);
}
int relation(Point b){//点和圆的关系//0 圆外//1 圆上//2 圆内
double dst=b.distance(p);
if(sgn(dst-r)<0)return 2;
else if(!sgn(dst-r))return 1;
return 0;
}
};
circle mincovercircle(Point *p,int n){ //c为圆心,r为半径
random_shuffle(p,p+n);
circle ans(p[0],0);
for(int i=1;i<n;++i)
if(!ans.relation(p[i])){//第一个点,在圆外
ans=circle(p[i],0);
for(int j=0;j<i;++j)if(!ans.relation(p[j])){//第二个点
Point O=(p[i]+p[j])/2;
ans=circle(O,p[i].distance(O));
for(int k=0;k<j;++k)if(!ans.relation(p[k])){//第三个点
O=circle(p[i],p[j],p[k]).p;//求外接圆圆心,三点必不共线
ans=circle(O,p[i].distance(O));
}
}
}
return ans;
}