Main topic
Space Minimum Ball cover
Ideas
Do some water problem qwq before rolling rough
CODE
#define _crt_secure_no_warnings#include <cmath>#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#define INF 1e15#define EPS 1e-7#define MAXusing namespace STD;structpointiii{DoubleX, y, Z; POINTIII (Const Double&_,Const Double&__,Const Double&___): X (_), Y (__), Z (___) {} pointiii () {} POINTIIIoperator+(ConstPOINTIII &a)Const{returnPOINTIII (x + a.x, y + a.y, z + a.z); } POINTIIIoperator*(Const Double&a)Const{returnPOINTIII (x * A, Y * A, Z * a); }voidRead () {scanf("%LF%LF%LF", &x, &y, &z); }}point[max];intPointsDoubleans, fin;inline unsigned intRand () {returnRAND () * RAND ();inline DoubleCalc (ConstPOINTIII &p1,ConstPOINTIII &p2) {return sqrt((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (P1.Y-P2.Y) + (p1.z-p2.z) * (P1.Z-P2.Z));}voidSA () {DoubleT =100.0;Doublex =0, y =0, z =0; for(inti =1; I <= points; ++i) x + = point[i].x, y + = Point[i].y, z + = point[i].z; POINTIII Now (x/points, y/points, z/points); Ans =inf; while(T > EPS) {intp =1; for(inti =2; I <= points; ++i)if(Calc (now, point[i]) > Calc (now, point[p]) p = i;DoubleR = Calc (now, point[p]); ans = min (ans, R); now.x + = (point[p].x-now.x)/R * T; Now.y + = (POINT[P].Y-NOW.Y)/R * T; Now.z + = (point[p].z-now.z)/R * T; T *=. 98; }}intMain () { while(scanf("%d", &points), points) { for(inti =1; I <= points; ++i) Point[i]. Read (); SA ();printf("%.5f\n", ans); }return 0;}
POJ 2069 Super Star Mountain climbing