太虚假了。

我为什么要手贱点开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. 【.NET 深呼吸】.net core 中的轻量级 Composition

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

  2. 人人网框架导入uidGenerator的ID生成方式

    人人网框架导入uidGenerator的ID生成方式 2019-03-11 LIUREN    SpringBoot2.0  uidGenerator  SpringBoot2.0  uidGener ...

  3. 在GDAL中添加GDALRasterizeGeometriesBuf函数

    缘起 GDAL的栅格化算法中有GDALRasterizeLayers.GDALRasterizeLayersBuf和GDALRasterizeGeometries函数,但是没有GDALRasteriz ...

  4. 飞思卡尔单片机P&E开发工具硬件及软件

    原文链接: http://blog.sina.com.cn/s/blog_8ebff8d7010121tm.html 1.HC(S)08系列 开发机硬件:USB-ML-12 CYCLONE PRO U ...

  5. Altium Designer重装后图标都变白板或都变一样的解决方法

    https://blog.csdn.net/qq_41995282/article/details/80372113

  6. 游戏开发中IIS常见支持MIME类型文件解析

    游戏开发中IIS常见支持MIME类型文件解析 .apkapplication/vnd.android .ipaapplication/vnd.iphone .csbapplication/octet- ...

  7. NameError:name ‘xrange’ is not defined

    运行某代码时,报错: NameError:name 'xrange' is not defined 原因: 在Python 3中,range()与xrange()合并为range( ).我的pytho ...

  8. mybatis #与$区别

    mybatis #与$区别 #{}变量解析到SQL有带引号字符串:如查询条件变量如:select * from user where name = #{name}; 为:select * from u ...

  9. 强化学习-时序差分算法(TD)和SARAS法

    1. 前言 我们前面介绍了第一个Model Free的模型蒙特卡洛算法.蒙特卡罗法在估计价值时使用了完整序列的长期回报.而且蒙特卡洛法有较大的方差,模型不是很稳定.本节我们介绍时序差分法,时序差分法不 ...

  10. 【转载】最强NLP预训练模型!谷歌BERT横扫11项NLP任务记录

    本文介绍了一种新的语言表征模型 BERT--来自 Transformer 的双向编码器表征.与最近的语言表征模型不同,BERT 旨在基于所有层的左.右语境来预训练深度双向表征.BERT 是首个在大批句 ...