HDU 3007:Buried memory
来源:互联网 发布:女儿出嫁父亲感人知乎 编辑:程序博客网 时间:2024/04/27 23:56
Buried memory
HDU - 3007Each 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.
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.
31.00 1.002.00 2.003.00 3.000
2.00 2.00 1.41
思路:
1.开始以某一个点为圆心,半径为0,判断其它点是否在这个圆内。如果其它点都在圆内。结束。
2.如果有一个点不在圆内,则以圆心和这个点连线的中点为圆心,连线长度的一半为半径,判断其它点是否在圆内。如果其它点都在圆内。结束
3.如果有一个点不在圆内,则以这三点求出这三点构成的三角形的外接圆的圆心,圆心到其中一点的距离为半径,判断其它点是否在圆内。
这样必然有解。
#include<bits/stdc++.h>using namespace std;int n;struct lenka{double x,y;double r;}a[1000];double dis(const lenka& x,const lenka& y){return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y));}int main(){while(cin>>n&&n){lenka ans;for(int i=0;i<n;i++)scanf("%lf%lf",&a[i].x,&a[i].y);if(n==1){printf("%0.2f %0.2f 0.00\n",a[0].x,a[0].y);continue;}ans.x=a[0].x,ans.y=a[0].y,ans.r=0;for(int i=1;i<n;i++){if(dis(ans,a[i])<=ans.r)continue;ans=a[i];ans.r=0;for(int j=0;j<i;j++){if(dis(ans,a[j])<=ans.r)continue;ans.x=(ans.x+a[j].x)/2;ans.y=(ans.y+a[j].y)/2;ans.r=dis(ans,a[j]);for(int k=0;k<j;k++){if(dis(a[k],ans)<=ans.r)continue;double x1=a[i].x,y1=a[i].y;double x2=a[j].x,y2=a[j].y;double x3=a[k].x,y3=a[k].y;//三点外接圆的圆心公式 ans.x=( (x1*x1-x2*x2+y1*y1-y2*y2)*(y1-y3)-(x1*x1-x3*x3+y1*y1-y3*y3)*(y1-y2) ) / (2*(y1-y3)*(x1-x2)-2*(y1-y2)*(x1-x3));ans.y=( (x1*x1-x2*x2+y1*y1-y2*y2)*(x1-x3)-(x1*x1-x3*x3+y1*y1-y3*y3)*(x1-x2) ) / (2*(y1-y2)*(x1-x3)-2*(y1-y3)*(x1-x2));ans.r=dis(ans,a[k]);}}}printf("%0.2f %0.2f %0.2f\n",ans.x,ans.y,ans.r);}return 0;}
阅读全文
1 0
- HDU 3007 Buried memory
- Buried memory(hdu 3007)
- HDU.3007 Buried memory
- HDU 3007:Buried memory
- acm hdu 3007 Buried memory
- hdu 3007 Buried memory(water)
- hdu 3007 Buried memory (最小圆覆盖)
- HDU 3007 Buried memory 最小圆覆盖
- HUD 3007 Buried memory
- HDU 3007 Buried memory (最小圆覆盖 凸包解法)
- HDU 3007 Buried memory(点集最小圆覆盖 模拟退火解法)
- HDOJ 3007 Buried memory 增量法最小圆覆盖
- [HDU3007]Buried memory(最小圆覆盖)
- Buried memory 简单几何之最小圆覆盖问题
- hdu 2871 Memory Control
- hdu 2871 Memory Control
- hdu 2871 Memory Control
- HDU 2871 Memory Control
- 4977_怪盗基德的滑翔翼
- UC伯克利提出小批量MH测试:令MCMC方法在自编码器中更强劲
- js数组使用JSON.stringify和toString的区别
- 经典论文阅读——DeepFashion: Powering Robust Clothes Recognition and Retrieval with Rich Annotations (CVPR 2
- Java 内存分配详解
- HDU 3007:Buried memory
- NYOJ 119 士兵杀敌(三)
- Vue.js 实现表单数据参数传递,以及不同独立按钮之间的参数传递
- 《GPU高性能编程CUDA实战》—— 《笔记一》——使用线程实现GPU上的矢量求和
- Web会话安全分析工具ProxyStrike
- Redis cluster on Windows
- 深入理解java垃圾回收机制
- 百炼-2972-确定进制-C语言-数制转换
- YOLO_tensorflow-master运行与参考记录 模型保存与运行