luogu 1337
这东西真玄学啊。。
在eps,delta,T之间改来改去。。。
在wa4,wa6,wa8之间轮转。
然后就过了。
爬山考虑合力然后移动即可。
eps要设的很小才行,布吉岛为森么
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
1 #include <bits/stdc++.h> 2 using namespace std; 3 typedef double db; 4 const db eps = 1e-14; 5 const db delta = 0.993; 6 const db INF = 1e100; 7 struct point{ 8 db x,y,w; 9 point operator + (const point &k1) const{return (point){k1.x+x,k1.y+y};} 10 point operator - (const point &k1) const{return (point){x-k1.x,y-k1.y};} 11 point operator * (db k1) const{return (point){x*k1,y*k1};} 12 db abs(){return sqrt(x*x+y*y);} 13 db dis(point k1){return ((*this)-k1).abs();} 14 }; 15 point p[1005];int n; 16 db mxx=1e18;point ans; 17 void sa(){ 18 db T = 2005; 19 while (T>eps){ 20 db x=ans.x+(rand()*2-RAND_MAX)*T,y=ans.y+(rand()*2-RAND_MAX)*T; 21 db z=0; 22 for(int i=1;i<=n;i++) 23 z+=sqrt((p[i].x-x)*(p[i].x-x)+(p[i].y-y)*(p[i].y-y))*p[i].w; 24 if(z<mxx){ 25 mxx=z; 26 ans={x,y}; 27 } 28 T*=delta; 29 } 30 } 31 int main(){ 32 scanf("%d",&n); 33 for(int i=1;i<=n;i++)scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].w); 34 sa();sa();sa(); 35 printf("%.3f %.3f\n",ans.x,ans.y); 36 }