地址:https://codeforces.com/gym/101981/attachments
代码:
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <ctime>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <math.h>
#include <map>
#include <sstream>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <array>
#include <climits>
using namespace std;
#define LL long long
#define ull unsigned long long
#define LD long double
const LL MAX = (LL)1e18;
const int N = 1e3 + 10;
const double eps = 1e-3;
const double PI = acos(-1);
typedef struct Point
{
double x, y, z;
Point operator -(const Point &u)const
{
return {x - u.x, y - u.y, z - u.z};
}
};
int n;
Point p[N];
double getlen(Point a, Point b)
{
Point d=a-b;
return sqrt(d.x * d.x + d.y * d.y + d.z * d.z);
}
double solve()
{
double st = 1000, rate = 0.99999;
Point now = p[1];
double ans = MAX;
while (st > eps)
{
int cur = 0;
double maxx =0;
for (int i = 1; i <= n; i++)
if (getlen(now, p[i]) > maxx) cur = i, maxx = getlen(now, p[i]);
ans = min(ans, getlen(now, p[cur]));
now.x += (p[cur].x - now.x) * (st / 1000);
now.y += (p[cur].y - now.y) * (st / 1000);
now.z+= (p[cur].z - now.z) * (st / 1000);
st *= rate;
}
//cout << now.x << " " << now.y << " " << now.z << endl;
return ans;
}
int main()
{
cin >> n;
for (int i = 1; i <= n; i++) cin >> p[i].x >> p[i].y >> p[i].z;
printf("%.10lf\n", solve());
return 0;
}