You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.2 KiB
C++
44 lines
1.2 KiB
C++
#define _CRT_SECURE_NO_WARNINGS
|
|
#define _SILENCE_CXX17_C_HEADER_DEPRECATION_WARNING
|
|
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
#define CRP(t, x) const t &x
|
|
#define OPL(t, x) bool operator<(CRP(t, x)) const
|
|
#define FIL(x, v) memset(x, v, sizeof(x))
|
|
#define CLR(x) FIL(x, 0)
|
|
#define NE1(x) FIL(x, -1)
|
|
#define INF(x) FIL(x, 0x3f)
|
|
#ifndef _DEBUG
|
|
#define _DEBUG 0
|
|
#endif // !_DEBUG
|
|
#define IFD if (_DEBUG)
|
|
typedef long long ll, i64;
|
|
constexpr double eps = 1e-8;
|
|
struct p
|
|
{
|
|
double x, y, z;
|
|
} a[105];
|
|
int n;
|
|
inline double dis2(CRP(p, a), CRP(p, b))
|
|
{
|
|
return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y) + (a.z - b.z) * (a.z - b.z);
|
|
}
|
|
int main()
|
|
{
|
|
scanf("%d", &n);
|
|
for (int i = 0; i < n; i++)
|
|
scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].z);
|
|
double ans = 1e30;
|
|
p z{0};
|
|
for (double step = 10000; step > eps; step *= 0.98)
|
|
{
|
|
p s = *max_element(a, a + n, [&z](CRP(p, a), CRP(p, b)) { return dis2(z, a) < dis2(z, b); });
|
|
double mx = sqrt(dis2(z, s));
|
|
ans = min(ans, mx);
|
|
z.x += (s.x - z.x) / mx * step;
|
|
z.y += (s.y - z.y) / mx * step;
|
|
z.z += (s.z - z.z) / mx * step;
|
|
}
|
|
printf("%.15lf\n", ans);
|
|
return 0;
|
|
} |