太虚假了。

我为什么要手贱点开submission?

这道题两天之前被一个学弟A了。

我退役了。

其实就是爬山吧。。好像有的题解还分方向什么的完全没必要吧。

 #include <iostream>
#include <cstdio>
#include <cmath>
#include <stdlib.h>
#define pii pair<int,int>
using namespace std;
typedef double db;
const db INF = 1e100;
const db delta = 0.98;
const db eps = 1e-;
int sign(db k){
if (k>eps) return ; else if (k<-eps) return -; return ;
}
int cmp(db k1,db k2){return sign(k1-k2);}
struct point {
db x,y;
point operator - (const point &k1)const { return point{x-k1.x,y-k1.y};};
db abs(){ return sqrt(x*x+y*y);}
db dis(point k1){ return ((*this)-k1).abs();}
};
db random(){
return (rand()&?:-)*rand()*1.0/;
}
int n;point p[];
point ans[];
db F(point x){
db res = ;
for(int i=;i<n;i++){
res+=x.dis(p[i]);
}
return res;
}
void SA(){
db t = ;
while (t>eps){
for(int i=;i<;i++){
db tmp = F(ans[i]);
for(int j=;j<;j++){
point _x=point{ans[i].x+random()*t,ans[i].y+random()*t};
db f = F(_x);
if(tmp>f) {
tmp = f;
ans[i]=_x;
}
}
}
t*=delta;
}
db ed = INF;
for(int i=;i<;i++)
ed=min(ed,F(ans[i]));
printf("%.0f",ed);
}
int main(){
ios::sync_with_stdio(false);
scanf("%d",&n);
for(int i=;i<n;i++){
scanf("%lf%lf",&p[i].x,&p[i].y);
}
SA();
}

poj 2420的更多相关文章

  1. 三分 POJ 2420 A Star not a Tree?

    题目传送门 /* 题意:求费马点 三分:对x轴和y轴求极值,使到每个点的距离和最小 */ #include <cstdio> #include <algorithm> #inc ...

  2. poj 2420,模拟退火算法,费马点

    题目链接:http://poj.org/problem?id=2420 题意:给n个点,找出一个点,使这个点到其他所有点的距离之和最小,也就是求费马点. 参考链接:http://www.cnblogs ...

  3. poj 2420 A Star not a Tree?——模拟退火

    题目:http://poj.org/problem?id=2420 精度设成1e-17,做三遍.ans设成double,最后再取整. #include<iostream> #include ...

  4. poj 2420 A Star not a Tree? —— 模拟退火

    题目:http://poj.org/problem?id=2420 给出 n 个点的坐标,求费马点: 上模拟退火. 代码如下: #include<iostream> #include< ...

  5. [POJ 2420] A Star not a Tree?

    A Star not a Tree? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4058   Accepted: 200 ...

  6. POJ 2420 A Star not a Tree?(模拟退火)

    题目链接 居然1Y了,以前写的模拟退火很靠谱啊. #include <cstdio> #include <cstring> #include <string> #i ...

  7. POJ 2420:A Star not a Tree?

    原文链接:https://www.dreamwings.cn/poj2420/2838.html A Star not a Tree? Time Limit: 1000MS   Memory Limi ...

  8. POJ 2420 A Star not a Tree? 爬山算法

    B - A Star not a Tree? Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hust.edu.cn/vjudge/co ...

  9. POJ 2420 A Star not a Tree? (计算几何-费马点)

    A Star not a Tree? Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 3435   Accepted: 172 ...

随机推荐

  1. hihocoder1051 补提交卡(贪心)

    http://hihocoder.com/problemset/problem/1051 一开始dfs暴搜超时 这题关键在于理解到,肯定是补连续的几天.所以说写贪心之前要好好想想,怎么贪. //补题卡 ...

  2. HTML5 学习07——Video(视频)Audio(音频)

    <video> 元素:提供了 播放.暂停和音量控件来控制视频. width 和 height 属性:控制视频的尺寸 <video> 与</video> 标签之间插入 ...

  3. Python计算分位数

    Python计算分位数    版权声明:本文为博主原创文章,未经博主允许不得转载. https://blog.csdn.net/gdkyxy2013/article/details/80911514 ...

  4. 【黑魔法】Covering Indexes、STRAIGHT_JOIN

    今天给大家介绍两个黑魔法,这都是压箱底的法宝.大家在使用时,一定要弄清他们的适用场景及用法,用好了,就是一把开天斧,用不好那就是画蛇添足.自从看过耗子哥(左耳朵耗子)的博客,都会给对相应专题有兴趣的小 ...

  5. DBS-Function:f_GetPy

    ylbtech-SQL Server-Function:f_GetPy   A, 返回顶部 1.f_GetPy )) ) as begin ) ) collate Chinese_PRC_CI_AS, ...

  6. 【.NET 深呼吸】.net core 中的轻量级 Composition

    记得前面老周写过在.net core 中使用 Composition 的烂文.上回老周给大伙伴们介绍的是一个“重量级”版本—— System.ComponentModel.Composition.应该 ...

  7. ES6 与 React

    Node和NPM/*安装npm*/npm installnpm install <package>npm install -g <package> /*更新安装包*/npm u ...

  8. [转]rsync命令中文文档

    原文链接 rsync是一个快速.多功能的远程(和本地)文件拷贝工具. 摘要 Local: rsync [OPTION...] SRC... [DEST] Access via remote shell ...

  9. MATLAB 程序计算结果出现 复数(a+bi)问题

    存在对负数开根号的情况了: >> (0.777)^0.1 ans = 0.9751 >> ( ans = 0.6037 >> (0.777)^2.1 ans = 0 ...

  10. Redis 学习之路 (011) - redis 多数据库

    一台服务器上都快开启200个redis实例了,看着就崩溃了.这么做无非就是想让不同类型的数据属于不同的应用程序而彼此分开. 那么,redis有没有什么方法使不同的应用程序数据彼此分开同时又存储在相同的 ...