bzoj 1337: 最小圆覆盖 (最小圆覆盖)

1337: 最小圆覆盖

Time Limit: 1 Sec   Memory Limit: 64 MB
Submit: 939   Solved: 463
[ Submit][ Status][ Discuss]

Description

给出平面上N个点,N<=10^5.请求出一个半径最小的圆覆盖住所有的点

Input

第一行给出数字N,现在N行,每行两个实数x,y表示其坐标.

Output

输出最小半径,输出保留三位小数.

Sample Input

4
1 0
0 1
0 -1
-1 0

Sample Output

1.000

HINT

Source

[ Submit][ Status][ Discuss]


题解:随机增量法求最小圆覆盖

#include
#include
#include
#include
#include
#define N 100005
#define eps 1e-7
using namespace std;
int n,m;
struct vector {
	double x,y;
	vector (double X=0,double Y=0){
		x=X,y=Y;
	}
}p[N],tmp;
double x,y,ans,r,pi=acos(-1.0);
typedef vector point;
vector operator -(vector a,vector b){
	return vector (a.x-b.x,a.y-b.y);
}
vector operator +(vector a,vector b){
	return vector (a.x+b.x,a.y+b.y);
}
vector operator *(vector a,double t){
	return vector (a.x*t,a.y*t);
}
vector operator /(vector a,double t){
	return vector (a.x/t,a.y/t);
}
int dcmp(double x)
{
	if (fabs(x)0){
		c=p[i]; r=0;
		for (int j=0;j0) {
		 	c=(p[i]+p[j])/2;
		 	r=len(c-p[i]);
		 	for (int k=0;k0) {
		 	 	c=center(p[i],p[j],p[k]);
		 	 	r=len(p[i]-c);
			  }
		 }
	}
	return r;
}
int main()
{
	freopen("a.in","r",stdin);
	freopen("my.out","w",stdout);
	scanf("%d",&n);
	for (int i=0;i


你可能感兴趣的:(计算几何)