Test instructions: Find out one point, the shortest distance from all points is maximum
Two-dimensional simulated annealing in the plane, the same problem with the smallest circle cover is also possible.
Source Code:
//#pragma COMMENT (linker, "/stack:16777216")//For C + + Compiler#include <stdio.h>#include<iostream>#include<fstream>#include<cstring>#include<cmath>#include<stack>#include<string>#include<map>#include<queue>#include<vector>#include<ctime>#include<algorithm>#defineLL Long Long#defineMax (b) ((a) > (b))? (a): (b))#defineMin (b) ((a) < (a))? (a): (b))#defineAbs (x) (((x) > 0)? (x): (-(x)))#defineMOD 1000000007#defineEPS 1e-8#definePi ACOs (-1.0)using namespacestd;Const intINF =0x3f3f3f3f;Const intN = the;Const intL = *;intT,n;DoubleX, Y, best[ -];structpoint{Doublex, y; BOOLCheck () {if(x >-eps && x < EPS + x && y >-eps && y < EPS +Y)return true; return false; }}p[1005],tp[ -];DoubleDist (Point p1,point p2) {returnsqrt ((p1.x-p2.x) * (p1.x-p2.x) + (P1.Y-P2.Y) * (p1.y-p2.y));}DoubleMin_dis (Point p0) {Doubleans = inf;// for(inti =0; I < n; ++i) ans= Min (ans,dist (p[i],p0));// returnans;} Point Rand_point (DoubleXDoubley) {point C; c.x= (rand ()% ++1) /1000.0*x; C.y= (rand ()% ++1) /1000.0*y; returnC;}intMain () {Srand (Time (NULL)); scanf ("%d",&t); while(t--) {scanf ("%lf%lf%d",&x,&y,&N); for(inti =0; I < n; ++i) scanf ("%LF%LF",&p[i].x,&p[i].y); for(inti =0; i < N; ++i) {Tp[i]=Rand_point (X, Y); Best[i]=Min_dis (Tp[i]); } DoubleStep = max (x, y)/sqrt (1.0*N); while(Step > 1e-3){ for(inti =0; i < N; ++i) {Point cur; Point Pre=Tp[i]; for(intj =0; J < L; ++j) { DoubleAngle = (rand ()% ++1) /1000.0*2*Pi; Cur.x= pre.x + cos (angle) *step; Cur.y= Pre.y + sin (angle) *step; if(!cur.check ())Continue; DoubleTMP =Min_dis (cur); if(tmp > Best[i]) {//Tp[i] =cur; Best[i]=tmp; }}} step*=0.85; } intIDX =0; for(inti =0; i < N; ++i) { if(Best[i] > Best[idx]) {//IDX =i; }} printf ("The safest point is (%.1f,%.1f). \ n", TP[IDX].X,TP[IDX].Y); //printf ("%.1f\n", Best[idx]); } return 0;}
POJ 1379 Run Away "basic simulated annealing"