http://acm.hdu.edu.cn/showproblem.php?pid=1109

一个范围内给一堆点,求到这些点的最短距离最大

模拟退火,温度是步长

#include <iostream>
#include <cstdio>
#include <cstring>
#include <map>
#include <ctime>
#include <cmath>
using namespace std ;
const double eps=1e- ;
int X,Y,M ; struct point
{
double x,y ;
int OK()
{
if(x>-eps && x<X+eps && y>-eps && y<Y+eps)return ;
return ;
}
}p[],r[] ; double dis(point a,point b)
{
return sqrt(pow(a.x-b.x,)+pow(b.y-a.y,)) ;
} double ans[] ; int main()
{
int T ;
scanf("%d",&T) ;
srand(time(NULL)) ;
while(T--)
{
scanf("%d%d%d",&X,&Y,&M) ;
for(int i= ;i<M ;i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y) ;
}
for(int i= ;i< ;i++)
{
r[i].x=(rand()%+)/1000.0*X ;
r[i].y=(rand()%+)/1000.0*Y ;
ans[i]=1e18 ;
for(int j= ;j<M ;j++)
{
ans[i]=min(ans[i],dis(p[j],r[i])) ;
}
}
double tmp=max(X,Y) ;
while(tmp>0.01)
{
for(int i= ;i< ;i++)
{
point now=r[i],next ;
for(int j= ;j< ;j++)
{
double rad=(rand()%+)/1000.0**3.1415926535 ;
next.x=now.x+cos(rad)*tmp ;
next.y=now.y+sin(rad)*tmp ;
if(!next.OK())continue ;
double m=1e18 ;
for(int k= ;k<M ;k++)
m=min(m,dis(p[k],next)) ;
if(m>ans[i])
{
ans[i]=m ;
r[i]=next ;
}
}
}
tmp*=0.8 ;
}
double res=0.0 ;
int idx ;
for(int i= ;i< ;i++)
{
if(ans[i]>res)
{
res=ans[i] ;
idx=i ;
}
}
printf("The safest point is (%.1lf, %.1lf).\n",r[idx].x,r[idx].y) ;
}
return ;
}

HDU 1109的更多相关文章

  1. HDU 1109 Run Away

    题目大意:给一个矩阵的长宽,再给n个点,求矩阵区域内某个点到各个点的最小距离的最大值,输出所求点的坐标 这道题我还是写了随机化乱搞,不过由于比较懒于是就没有写模拟退火,不过也是可以AC的 我们先初始随 ...

  2. HDU 5643 King's Game 打表

    King's Game 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5643 Description In order to remember hi ...

  3. 转载:hdu 题目分类 (侵删)

    转载:from http://blog.csdn.net/qq_28236309/article/details/47818349 基础题:1000.1001.1004.1005.1008.1012. ...

  4. HDOJ 2111. Saving HDU 贪心 结构体排序

    Saving HDU Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total ...

  5. 【HDU 3037】Saving Beans Lucas定理模板

    http://acm.hdu.edu.cn/showproblem.php?pid=3037 Lucas定理模板. 现在才写,noip滚粗前兆QAQ #include<cstdio> #i ...

  6. hdu 4859 海岸线 Bestcoder Round 1

    http://acm.hdu.edu.cn/showproblem.php?pid=4859 题目大意: 在一个矩形周围都是海,这个矩形中有陆地,深海和浅海.浅海是可以填成陆地的. 求最多有多少条方格 ...

  7. HDU 4569 Special equations(取模)

    Special equations Time Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64u S ...

  8. HDU 4006The kth great number(K大数 +小顶堆)

    The kth great number Time Limit:1000MS     Memory Limit:65768KB     64bit IO Format:%I64d & %I64 ...

  9. HDU 1796How many integers can you find(容斥原理)

    How many integers can you find Time Limit:5000MS     Memory Limit:32768KB     64bit IO Format:%I64d ...

随机推荐

  1. 意外的节点类型 Element。只能在简单内容或空内容上调用 ReadElementString 方法

    问题出现的情景: 在调用携程团购接口时,需要把获取的xml字符串反序列化实体对象,出现了这个错误. 详情: 在对xml文档有这样一条语句“ <Description Category=" ...

  2. UI-简答的BOL的取值塞值

    不知道从什么时候开始,习惯用BOL MODEL来做一些东西的了.某个项目开始正式接触标准主数据的时候,开始了用MAINTAIN BAPI和BUPA的一些FM.然后在一段时间内是以此类的FM来开发的.B ...

  3. HDU4815

    Little Tiger vs. Deep Monkey Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65535/65535 K ( ...

  4. 生成json对象

    JSONObject 对于放入的object,最终生成的json是什么样的? 两个JavaBean: public class ClassBean { private int grade; priva ...

  5. SecureCRT快捷键

    ctrl + a :  移动光标到行首ctrl + e :移动光标到行尾crtl + b:  光标前移1个字符crtl + f :  光标后移1个字符 crtl + h :  删除光标之前的一个字符c ...

  6. [工作需求]linux常用命令以及vim常用命令

    一.             Linux 常用命令 mkdir dirname新建文件夹 cd ~ 进入自己的家目录 cd dirname 进入名字为dirname的目录: l 显示当前文件夹下的文件 ...

  7. centos6.5 64位系统安装 tengine

          1 安装pcre 下载好pcre 上传到服务器 我用的版本是pcre-8.31.tar.gz tar -zxvf pcre-8.31.tar.gz cd pcre-8.31 ./confi ...

  8. 统计sql语句执行效率

    --统计sql语句执行效率SELECT (total_elapsed_time / execution_count)/1000 N'平均时间ms' ,total_elapsed_time/1000 N ...

  9. bzoj 2127: happiness

    #include<cstdio> #include<iostream> #include<cstring> #define M 100009 #define inf ...

  10. putty基本操作

    1,进入全屏 标题栏右键,菜单中就有full screen选项. 2,退出全屏 鼠标移到左上角,单击鼠标左键,就会跳出菜单,full screen勾去掉. 3,从putty中复制内容到剪切板 鼠标左键 ...