博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Buried memory HDU - 3007(计算几何)
阅读量:4136 次
发布时间:2019-05-25

本文共 2290 字,大约阅读时间需要 7 分钟。

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
昨天想刷刷模拟退火的题目呢,就看到这个题了。不清楚这个题用模拟退火行不行,不过不用也可以。
想要找个圆心和半径用把所有的炸弹都引爆。
假如只有一个点,我们直接在那个点上引爆就行。
假如有两个点,我们就在这两点连线的中点引爆,半径是连线距离的一半。
假如有三个点,我们就在三点形成三角形的外接圆的圆心引爆,半径是圆心距离任意一点的距离。
假设点数打于三,我们就重复上面的过程,总会有某几个点形成的连线或者三角形可以包围所有的点。这样就把圆心和半径找出来了。
代码如下:

#include
#define ll long longusing namespace std;const int maxx=1e3+100;struct node{
double x,y; double r;}a[maxx];int n;inline void read(){
for(int i=1;i<=n;i++) scanf("%lf%lf",&a[i].x,&a[i].y);}inline double dis(node a,node b){
return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));}inline void solve(){
node ans=a[1];ans.r=0; for(int i=2;i<=n;i++) {
if(dis(ans,a[i])<=ans.r) continue; ans=a[i];ans.r=0.0; for(int j=1;j

努力加油a啊,(o)/~

转载地址:http://uztvi.baihongyu.com/

你可能感兴趣的文章
leetcode——Combinations
查看>>
中兴笔试
查看>>
程序员笔试面试常见题总结,更新ing
查看>>
阿里笔试--软开C/C++
查看>>
腾讯笔试--移动客户端软件开发工程师
查看>>
360在线测试--嵌入式软开
查看>>
优化程序性能—《深入理解计算机系统》
查看>>
《演讲的艺术》有感
查看>>
《亲密关系》摘录
查看>>
win7下安装centOS7双系统
查看>>
Linux鸟哥的私房菜—1
查看>>
matlab 批处理图片
查看>>
每日总结-1
查看>>
python学习之 打包脚本
查看>>
Android开发华为手机无法看log日志解决方法
查看>>
Android 关于在Activity中监听ListView
查看>>
Android xUtils3.0使用手册(二) - 数据库操作
查看>>
护眼颜色设置
查看>>
Android RecyclerView体验(一)- 简介
查看>>
Android tools:context=".MainActivity"的作用
查看>>