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 ...
随机推荐
- Spring HibernateTemplate的使用
Spring HibernateTemplate的使用 2008-03-25 11:38 2020人阅读 评论(0) 收藏 举报 springbeanhibernatesessiondaoclass ...
- python之安装
1.python控制软件pyenv 依赖软件:git [root@localhost ~]# curl https://raw.github.com/yyuu/pyenv-installer/mast ...
- 树上战争(HDU 2545 并查集求解点到根节点长度)
树上战争 Time Limit: 10000/4000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submi ...
- 优先队列(和fence repair完全一样)
懒省事的小明 时间限制:3000 ms | 内存限制:65535 KB 难度:3 描述 小明很想吃果子,正好果园果子熟了.在果园里,小明已经将所有的果子打了下来,而且按果子的不同种 ...
- ASP.NET MVC 4.0 学习6-Model Binding
一,ViewData,ViewBag與TempData ASP.NET MVC架構中,通過繼承在Controller中的ViewData,ViewBag和TempData和View頁面進行資料的存取, ...
- 给ie浏览器添加推荐浏览器提示
<script type="text/javascript"> var isIE = !!window.ActiveXObject; var isIE6 = isIE ...
- (转)ZOJ 3687 The Review Plan I(禁为排列)
The Review Plan I Time Limit: 5 Seconds Memory Limit: 65536 KB Michael takes the Discrete Mathe ...
- orcl改变临时表空间的指令
sqlplus / as sysdba: alter database tempfile 'D:\oracle\product\10.2.0\oradata\zhongnan\temp01.dbf' ...
- sendto() 向广播地址发包返回errno 13, Permission denied错误
http://blog.csdn.net/guanghua2_0beta/article/details/52483916 sendto() 向广播地址发包返回errno 13, Permission ...
- UGUI Toggle控件
今天我们来看看Toogle控件, 它由Toogle + 背景 + 打勾图片 + 标签组成的. 它主要用于单选和多选 属性讲解: Is On: 代表是否选中. Toogle Transition: 在状 ...