三分-2025/11/16

三分

#include<bits/stdc++.h>
using namespace std;

const int N = 1e5 + 10;

int n;
typedef struct{
	int x,y;
}Point;

Point p[N];

double check(double x){
	double res = 0.0;
	for(int i = 1; i <= n; i++){
		res = max(res , sqrt((x - p[i].x) * (x - p[i].x) + p[i].y * p[i].y));
	}
	return res;
}

double three(double l, double r){
	
	for(int i = 1; i <= 100; i++){
		double mid1 = l + (r - l) / 3 , mid2 = l + (r - l) * 2 / 3;
		if(check(mid1) > check(mid2)){
			l = mid1;
		}
		else r = mid2;
	}
	
	return check(l);
}

int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d %d", &p[i].x, &p[i].y);
	
	double ans = three(-10000,10000);
	
	printf("%lf", ans);
	
	return 0;
}
posted @ 2025-11-28 23:00  XYu1230  阅读(4)  评论(0)    收藏  举报