First, the name of this question should be changed to the target person.
Given N points, calculate the center of gravity
The center of gravity of the N points satisfies the minimum x g [I] of Σ (distance from the center of gravity to I ).
Bare questions of Simulated Annealing
Nima handed in two articles and failed to modify various parameters. Finally, I found that my INF was not big enough Nima!
This question INF should be opened 0x3 F... At least max_of _ long_long is required.
At last, 10188 MS was written, and bzoj was the penultimate ...... This is also an art. 0.0
# Include <cmath> # include <cstdio> # include <cstring> # include <iostream> # include <algorithm> # define M 10100 using namespace STD; struct point {Double X, y, G;} points [m], ans; int N; double minans = 23333333333333333ll; double DIS (const point & X, const point & Y) {return SQRT (X. x-y.x) * (X. x-y.x) + (X. y-y.y) * (X. y-y.y);} double judge (const point & P) {int I; double Re = 0; for (I = 1; I <= N; I ++) re + = points [I]. g * Dis (p, points [I]); If (Re <minans) ans = P, minans = Re; return re;} double rand () {return rand () % 1000/1000. 0;} void SA (double T) {int I; point now = ans; while (T> 0.001) {point NEO; Neo. X = now. X + T * (RAND () * 2-1); Neo. y = now. Y + T * (RAND () * 2-1); double de = judge (now)-judge (NEO ); if (de> 0 | exp (DE/T)> rand () now = NEO; T * = 0.993;} for (I = 1; I <= 1000; I ++) {point NEO; Neo. X = ans. X + T * (RAND () * 2-1); Neo. y = ans. Y + T * (RAND () * 2-1); Judge (NEO) ;}} int main () {int I; srand (19970815); CIN> N; for (I = 1; I <= N; I ++) {scanf ("% lf", & points [I]. x, & points [I]. y, & points [I]. g); ans. X + = points [I]. x; ans. Y + = points [I]. y;} ans. x/= N; ans. y/= N; SA (1000000); printf ("%. 3lf %. 3lf \ n ", ans. x, ans. Y );}
Bzoj 3680 hanging XXX Simulated Annealing