题意:http://www.lydsy.com/JudgeOnline/problem.php?id=3680
sol :吊打出题人(逃~
puts("nan")
出题人题解:http://bakser.blog.163.com/blog/static/23589413220147161124294/
数学&物理结合QAQ,喜sang闻xin乐bing见kuang
引入一下广义费马点:http://www.matrix67.com/blog/archives/422
然后爬山or退火乱搞即可
#include<iostream> #include<cstdio> #include<cmath> #define eps 0.00000001 using namespace std; const int Mx=10010; double x,y,tmp=1000,ansx,ansy; struct Node { double x,y; int w; } str[Mx]; double dis(double x,double y,Node z) { return sqrt((x-z.x)*(x-z.x)+(y-z.y)*(y-z.y)); } int main() { int n; scanf("%d",&n); for(int i=1;i<=n;i++) scanf("%lf%lf%d",&str[i].x,&str[i].y,&str[i].w); for(int i=1;i<=n;i++) ansx+=str[i].x*str[i].w,ansy+=str[i].y*str[i].w; ansx/=n;ansy/=n; while(tmp>eps) { x=y=0; for(int i=1;i<=n;i++) { x+=(str[i].x-ansx)*str[i].w/dis(ansx,ansy,str[i]); y+=(str[i].y-ansy)*str[i].w/dis(ansx,ansy,str[i]); } ansx+=x*tmp,ansy+=y*tmp; if(tmp>0.5) tmp*=0.5; else tmp*=0.97; } printf("%.3lf %.3lf ",ansx,ansy); return 0; }