Buried memory

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 4067    Accepted Submission(s): 2171

Problem Description
Each person had do something foolish along with his or her growth.But,when he or she did this that time,they could not predict that this thing is a mistake and they will want this thing would rather not happened.
The world king Sconbin is not the exception.One day,Sconbin was sleeping,then swakened by one nightmare.It turned out that his love letters to Dufein were made public in his dream.These foolish letters might ruin his throne.Sconbin decided to destroy the letters by the military exercises's opportunity.The missile is the best weapon.Considered the execution of the missile,Sconbin chose to use one missile with the minimum destruction.
Sconbin had writen N letters to Dufein, she buried these letters on different places.Sconbin got the places by difficult,he wants to know where is the best place launch the missile,and the smallest radius of the burst area. Let's help Sconbin to get the award.
 
Input
There are many test cases.Each case consists of a positive integer N(N<500,^V^,our great king might be a considerate lover) on a line followed by N lines giving the coordinates of N letters.Each coordinates have two numbers,x coordinate and y coordinate.N=0 is the end of the input file.
 
Output
For each case,there should be a single line in the output,containing three numbers,the first and second are x and y coordinates of the missile to launch,the third is the smallest radius the missile need to destroy all N letters.All output numbers are rounded to the second digit after the decimal point.
 
Sample Input
3
1.00 1.00
2.00
2.00
3.00 3.00
0
 
Sample Output
2.00 2.00 1.41

做法类似POJ2069

请参考:https://www.cnblogs.com/qq965921539/p/9806603.html

 #include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
#define it iterator
#define ll long long
#define eb emplace_back
#define lowbit(x) x & -x
#define all(x) x.begin(),x.end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define per(x,a,b) for(int x = a; x <= b; x++)
#define rep(x,a,b) for(int x = a; x >= b; x--)
#define IO ios::sync_with_stdio(false),cin.tie(0),cout.tie(0) const int birth = ;
const int mo = ;
const int maxn = 1e5 + ;
const int mod = 1e9 + ;
const int INF = 0x3fffffff;
const double eps = 1e-; //******************THE PROGRAM BEGINING******************
struct node
{
double x, y;
}p[],now; double dis(node a, node b)
{
return sqrt(pow(a.x - b.x, ) + pow(a.y - b.y, ));
} double solve(int n)
{
double ans, cmp;
double T = 100.0;
double delat = 0.98;
now.x = now.y = 0.0;
int pos = ;
while (T > eps)
{
pos = ;
ans = dis(now, p[pos]);
per(i, , n - )
{
cmp = dis(now, p[i]);
if (cmp > ans)
{
pos = i;
ans = cmp;
}
}
now.x += (p[pos].x - now.x) / ans * T;
now.y += (p[pos].y - now.y) / ans * T;
T *= delat;
}
return ans;
} int main()
{
int n;
while (scanf("%d", &n) && n)
{
per(i, , n - )
scanf("%lf %lf", &p[i].x, &p[i].y);
double ans = solve(n);
printf("%.2lf %.2lf %.2lf\n", now.x, now.y, ans);
}
return ;
}

HDU 3007 模拟退火算法的更多相关文章

  1. hdu 5017 模拟退火算法

    hdu 5017 http://blog.csdn.net/mypsq/article/details/39340601 #include <cstdio> #include <cs ...

  2. 初探 模拟退火算法 POJ2420 HDU1109

    模拟退火算法来源于固体退火原理,更多的化学物理公式等等这里不再废话,我们直接这么来看 模拟退火算法简而言之就是一种暴力搜索算法,用来在一定概率下查找全局最优解 找的过程和固体退火原理有所联系,一般来讲 ...

  3. [HDU1109]模拟退火算法

    模拟退火的基本思想: (1) 初始化:初始温度T(充分大),初始解状态S(是算法迭代的起点),每个T值的迭代次数L (2) 对k=1,……,L做第(3)至第6步: (3) 产生新解$S\prime $ ...

  4. 模拟退火算法-[HDU1109]

    模拟退火算法的原理模拟退火算法来源于固体退火原理,将固体加温至充分高,再让其徐徐冷却,加温时,固体内部粒子随温升变为无序状,内能增大,而徐徐冷却时粒子渐趋有序,在每个温度都达到平衡态,最后在常温时达到 ...

  5. 【高级算法】模拟退火算法解决3SAT问题(C++实现)

    转载请注明出处:http://blog.csdn.net/zhoubin1992/article/details/46453761 ---------------------------------- ...

  6. 模拟退火算法(SA)求解TSP 问题(C语言实现)

    这篇文章是之前写的智能算法(遗传算法(GA).粒子群算法(PSO))的补充.其实代码我老早之前就写完了,今天恰好重新翻到了,就拿出来给大家分享一下,也当是回顾与总结了. 首先介绍一下模拟退火算法(SA ...

  7. 原创:工作指派问题解决方案---模拟退火算法C实现

    本文忽略了对于模拟退火的算法的理论讲解,读者可参考相关的博文或者其他相关资料,本文着重于算法的实现: /************************************************ ...

  8. BZOJ 3680: 吊打XXX【模拟退火算法裸题学习,爬山算法学习】

    3680: 吊打XXX Time Limit: 10 Sec  Memory Limit: 128 MBSec  Special JudgeSubmit: 3192  Solved: 1198[Sub ...

  9. OI骗分神器——模拟退火算法

    前言&&为什么要学模拟退火 最近一下子学了一大堆省选算法,所以搞一个愉快一点的东西来让娱乐一下 其实是为了骗到更多的分,然后证明自己的RP. 说实话模拟退火是一个集物理与IT多方面知识 ...

随机推荐

  1. struts2配置默认首页

    配置struts2 默认欢迎页的几种办法: 1.首先需要明确的是struts过滤器配置映射的模式是路径匹配还是扩展匹配,如果url-pattern配置为/*,如果不做特殊处理,是不会转到welcome ...

  2. java.io.CharConversionException: Not an ISO 8859-1 character:

    java.io.CharConversionException: Not an ISO 8859-1 character: XXX 这个问题可能是因为outputstream输出中文字造成的影响. r ...

  3. Bean标签的常用属性

    -----------------siwuxie095 Bean 标签的常用属性 1.id 属性:Bean 的唯一标识名,必须以字母开头,且不能 包含特殊字符 2.class 属性:用来定义类的全限定 ...

  4. HTML 页面中的 SVG

    SVG 文件可通过以下标签嵌入 HTML 文档:<embed>.<object> 或者 <iframe>. 1>使用 <embed> 标签 < ...

  5. catkin

    catkin  ros https://github.com/dirkholz/pcl_online_viewer rosrun  ???

  6. Django web 应用 http 协议 web框架

    一:什么是web 应用程序 Web应用程序是一种可以通过Web访问的应用程序,程序的最大好处是用户很容易访问应用程序,用户只需要有浏览器即可,不需要再安装其他软件 应用程序有两种模式C/S.B/S. ...

  7. UVa 12093 Protecting Zonk (树形DP)

    题意:给定一个有n个节点的无根树,有两种装置A和B,每种都有无限多个.在某个节点X使用A装置需要C1的花费,并且此时与节点X相连的边都被覆盖.在某个节点X使用B装置需要C2的花费,并且此时与节点X相连 ...

  8. C++ 数据封装和抽象

    C++ 数据抽象 数据抽象是指,只向外界提供关键信息,并隐藏其后台的实现细节,即只表现必要的信息而不呈现细节. 数据抽象是一种依赖于接口和实现分离的编程(设计)技术. 让我们举一个现实生活中的真实例子 ...

  9. cron.c

    /* $OpenBSD: cron.c,v 1.39 2007/02/18 23:59:03 jmc Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul ...

  10. underscore概况

    看的是1.3.3,这个版本的中文源码解释比较多. 函数的中文注释:http://www.css88.com/doc/underscore1.5.2/#difference 源码的中文注释:http:/ ...