quoit design(hdoj p1007)
In the field of Cyberground, the position of each toy is fixed, and
the ring is carefully designed so it can only encircle one toy at a time. On the
other hand, to make the game look more attractive, the ring is designed to have
the largest radius. Given a configuration of the field, you are supposed to find
the radius of such a ring.
Assume that all the toys are points on a
plane. A point is encircled by the ring if the distance between the point and
the center of the ring is strictly less than the radius of the ring. If two toys
are placed at the same point, the radius of the ring is considered to be
0.
case, the first line contains an integer N (2 <= N <= 100,000), the total
number of toys in the field. Then N lines follow, each contains a pair of (x, y)
which are the coordinates of a toy. The input is terminated by N = 0.
ring required by the Cyberground manager, accurate up to 2 decimal places.
0
#include<stdio.h>/*此题坐标按照y升序排列,然后进行计算比较*/
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef struct
{
double x,y;
}node;
node a[];
int cmp(node p,node q)/*对结构体排序*/
{
return p.y<q.y;
}
int main()
{
int T;
while(scanf("%d",&T)==)
{
if(!T)
break;
else
{
int i,j;
double min1=99999999.0,min;
double d;
for(i=;i<T;i++)
scanf("%lf%lf",&a[i].x,&a[i].y);
sort(a,a+T,cmp);
for(i=;i<T-;i++)
{
d=pow(a[i+].x-a[i].x,)+pow(a[i+].y-a[i].y,);
min1=d<min1?d:min1;
}
printf("%.2lf\n",sqrt(min1)/);/*最后在开方,节省时间*/
}
}
}
#include<stdio.h>/*我先按照x升序排列,求最小距离,在按照y升序排列求最小,然后比较,结果还WA了,果断怀疑这题数据给的有问题,讨论组也这么喷!*/
#include<math.h>
#include<stdlib.h>
#include<algorithm>
using namespace std;
typedef struct
{
double x,y;
}node;
node a[];
int cmp1(node p,node q)
{
return p.x<q.x;
}
int cmp2(node p,node q)
{
return p.y<q.y;
}
int main()
{
int T;
while(scanf("%d",&T)==)
{
if(!T)
break;
else
{
int i,j;
double min1=99999999.0,min2=99999999.0,min;
double d;
for(i=;i<T;i++)
scanf("%lf%lf",&a[i].x,&a[i].y);
sort(a,a+T,cmp1);
for(i=;i<T-;i++)
{
d=pow(a[i+].x-a[i].x,)+pow(a[i+].y-a[i].y,);
min1=d<min1?d:min1;
}
sort(a,a+T,cmp2);
for(i=;i<T-;i++)
{
d=pow(a[i+].x-a[i].x,)+pow(a[i+].y-a[i].y,);
min2=d<min2?d:min2;
}
min=sqrt(min1>min2?min2:min1)/;
printf("%.2lf\n",min);
}
}
}
quoit design(hdoj p1007)的更多相关文章
- HDU 1007 Quoit Design(二分+浮点数精度控制)
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- HDU1007 Quoit Design 【分治】
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- 杭电OJ——1007 Quoit Design(最近点对问题)
Quoit Design Problem Description Have you ever played quoit in a playground? Quoit is a game in whic ...
- ACM-计算几何之Quoit Design——hdu1007 zoj2107
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
- (hdu 7.1.8)Quoit Design(最低点——在n一个点,发现两点之间的最小距离)
主题: Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) T ...
- Quoit Design(最近点对+分治)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1007 Quoit Design Time Limit: 10000/5000 MS (Java/Oth ...
- Quoit Design(hdu1007)最近点对问题。模版哦!
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- ZOJ 2017 Quoit Design 经典分治!!! 最近点对问题
Quoit Design Time Limit: 5 Seconds Memory Limit: 32768 KB Have you ever played quoit in a playg ...
- poj 1007 Quoit Design(分治)
Quoit Design Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) To ...
随机推荐
- python的时间模块
python有两个重要的时间模块,分别是time和datetime 先看time模块 表示时间的几种方法: 1)时间元组:time.struct_time(tm_year=2016, tm_mon ...
- 改进我们的小游戏 - 零基础入门学习Python004
改进我们的小游戏 让编程改变世界 Change the world by program 改进我们的小游戏 很多鱼油对改善这个游戏提出了建议,小甲鱼做了一下总结,大概有以下几个方面需要改进: 猜错的时 ...
- ubuntu studio
相对于普通的的Ubuntu Linux而言,Ubuntu Studio更适合于多媒体设计人员,也就是说Ubuntu Studio更适合经常搞图片和电脑音乐的Linux爱好者们. Ubuntu Stud ...
- 前端上将字符串用语音读出来只能在IE上运行 其他不行 代码极少
先保存保存自己的笔记 有高手看到求指点 <script type="text/javascript"> var VoiceObj; try { VoiceObj = n ...
- android系统的图片资源
使用系统的图片资源的好处有,一个是美工不需要重复的做一份已有的图片了,可以节约不少工时:另一个是能保证我们的应用程序的风格与系统一致. 1.引用方式 在源代码*.Java中可以进入如下方式引用: my ...
- OpenJudge Trans
#include<iostream>#include<cstdio>#include<algorithm>#include<cmath>#include ...
- 【LeetCode练习题】Swap Nodes in Pairs
Swap Nodes in Pairs Given a linked list, swap every two adjacent nodes and return its head. For exam ...
- 二分图带权最大独立集 网络流解决 hdu 1569
方格取数(2) Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total S ...
- 用Python实现九九乘法表
1.用“#”组成的矩形的实现 代码 eight = int(input("Height:")) #用户输入高度 width = int(input("Width:&quo ...
- Django 从零開始
1.下载安装django 方法1: pip install Django==1.6.5 測试是否成功安装 : ~$ python import django ~$ (1, 6, 5, 'final', ...