和刚才那道是一模一样

不过求的是最小的,只要稍微修改一下就可以了~

//#pragma comment(linker, "/STACK:16777216") //for c++ Compiler
#include <stdio.h>
#include <iostream>
#include <fstream>
#include <cstring>
#include <cmath>
#include <stack>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <ctime>
#include <algorithm>
#define LL long long
#define Max(a,b) (((a) > (b)) ? (a) : (b))
#define Min(a,b) (((a) < (b)) ? (a) : (b))
#define Abs(x) (((x) > 0) ? (x) : (-(x)))
#define MOD 1000000007
#define eps 1e-8
#define pi acos(-1.0) using namespace std; const int inf = 0x3f3f3f3f;
const int N = ;
const int L = ; int t,n;
double X ,Y, best[]; struct Point{
double x,y;
bool check(){
if(x > -eps && x < eps + X && y > -eps && y < eps + Y)
return true;
return false;
}
}p[],tp[]; double dist(Point p1,Point p2){
return sqrt((p1.x-p2.x) * (p1.x-p2.x) + (p1.y-p2.y) * (p1.y-p2.y));
} double min_dis(Point p0){
double ans = ;//
for(int i = ; i < n; ++i)
ans = max(ans,dist(p[i],p0));//
return ans;
} Point rand_point(double x, double y){
Point c;
c.x = (rand() % + ) / 1000.0 * x;
c.y = (rand() % + ) / 1000.0 * y;
return c;
} int main(){
srand(time(NULL));
while(EOF != scanf("%lf%lf%d",&X,&Y,&n)){
for(int i = ; i < n; ++i)
scanf("%lf%lf",&p[i].x,&p[i].y);
for(int i = ; i < N; ++i){
tp[i] = rand_point(X, Y);
best[i] = min_dis(tp[i]);
}
double step = max(X,Y) / sqrt(1.0 * n);
while(step > 1e-){
for(int i = ; i < N; ++i){
Point cur;
Point pre = tp[i];
for(int j = ; j < L; ++j){
double angle = (rand() % + ) / 1000.0 * * pi;
cur.x = pre.x + cos(angle) * step;
cur.y = pre.y + sin(angle) * step;
if(!cur.check()) continue;
double tmp = min_dis(cur);
if(tmp < best[i]){//
tp[i] = cur;
best[i] = tmp;
}
}
}
step *= 0.85;
}
int idx = ;
for(int i = ; i < N; ++i){
if(best[i] < best[idx]){//
idx = i;
}
}
printf("(%.1f,%.1f).\n",tp[idx].x,tp[idx].y);
printf("%.1f\n",best[idx]);
}
return ;
}

HDU 3932 Groundhog Build Home 【基础模拟退火】的更多相关文章

  1. hdu 3932 Groundhog Build Home

    Groundhog Build Home Time Limit: 15000/5000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Ot ...

  2. hdu 3932 Groundhog Build Home —— 模拟退火

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3932 找一个位置使距离最远的点的距离最小: 上模拟退火: 每次向距离最远的点移动,注意判断一下距离最远的点 ...

  3. hdu 3932 Groundhog Build Home——模拟退火

    题目:http://acm.hdu.edu.cn/showproblem.php?pid=3932 注意平均值与最远的点距离为0的情况.所以初值设成-1,这样 id 就不会乱.不过设成0也可以.注意判 ...

  4. hdu 2215 & hdu 3932(最小覆盖圆)

    Maple trees Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total ...

  5. Groundhog Build Home - HDU - 3932(模拟退火)

    题意 给定一个矩形内的\(n\)个点,在矩形中找一个点,离其他点的最大距离最小. 题解 模拟退火. 这个题需要\(x\)和\(y\)坐标随机动的时候多随机几次.否则就WA了.另外由于随机多次,如果温度 ...

  6. HDU 3932 模拟退火

    HDU3932 题目大意:给定一堆点,找到一个点的位置使这个点到所有点中的最大距离最小 简单的模拟退火即可 #include <iostream> #include <cstdio& ...

  7. HDU 3932

    http://acm.hdu.edu.cn/showproblem.php?pid=3932 一定范围的平面上给一些点,求到这些点的最大距离最小,和上一题的题意正好相反,稍微改一下就可以 这个问题又叫 ...

  8. POJ 1379 Run Away 【基础模拟退火】

    题意:找出一点,距离所有所有点的最短距离最大 二维平面内模拟退火即可,同样这题用最小圆覆盖也是可以的. Source Code: //#pragma comment(linker, "/ST ...

  9. hdu 1711 Number Sequence KMP 基础题

    Number Sequence Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) ...

随机推荐

  1. PHP学习笔记12-上传文件

    上传图片文件并在页面上显示出图片 enctype介绍:enctype属性指定将数据发回到服务器时浏览器使用的编码类型. 取值说明: multipart/form-data: 窗体数据被编码为一条消息, ...

  2. python自学笔记(十一)关于函数及书写格式

    1.函数是抽象的第一步       1.1 有关高压锅     1.2 函数是抽象出来的结构,是总结,是方法     1.3 多用函数     2.如何定义函数        2.1 def是关键词, ...

  3. BeanUtils复制属性

    package xiao; public class User2 { private String name; private String password; public String getNa ...

  4. python2.6升级到2.7

    开发部需要使用python2.7,由于公网的环境python版本都是系统自带的,版本是2.6,需要升级,最好是通过RPM升级. Linux系统:CentOS CentOS 6.4升级Python后yu ...

  5. CSS3属性值之box-shadow

    语法:   box-shadow:inset x-offset y-offset blur-radius spread-radius color 也就是:   对象选择器 {box-shadow:投影 ...

  6. 转换DataSet中的多个表为Excel中的多个Sheets

    第一种方法: 1. 在设计页面,有一个button按钮,当用户单击按钮的时候,发生转换 <asp:Button ID="Export" runat="server& ...

  7. TreeView控件绑定数据库

    1.在设计视图里面的代码 <form id="form1" runat="server"> <div> <h1>两个表< ...

  8. mac安装office2011,提示无法打开文件Normal.dotm,因为内容有错误

    最近使用mac上的office,发现一个问题,每次打开office11都会报错,提示“无法打开文件Normal.dotm,因为内容有错误”,于是就在网络上搜索了一下,找到如下一段话, I just f ...

  9. Joel在耶鲁大学的演讲

    Joel Spolsky是一个美国的软件工程师,他的网络日志"Joel谈软件"(Joel on Software)非常有名,读者人数可以排进全世界前100名. 上个月28号,他回到 ...

  10. was服务器下修改jsp无效果

    使用了jsp静态导入,修改了导入的jsp页面,但是目标页面没出现效果.先说下静态导入和动态导入的区别: include指令用于引入其它JSP页面,如果使用include指令引入了其它JSP页面,那么J ...