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 ...
随机推荐
- debian修改系统语言为英文
原文地址:http://www.chenyudong.com/archives/debian-change-locale-language.html 修改/etc/default/locale 文件里 ...
- WordPress插件制作教程(一): 如何创建一个插件
上一篇还是按照之前的教程流程,写了一篇WordPress插件制作教程概述,从这一篇开始就为大家具体讲解WordPress插件制作的内容.这一篇主要说一下插件的创建方法. 相信大家都知道插件的安装文件在 ...
- python运维开发(二十二)---JSONP、瀑布流、组合搜索、多级评论、tornado框架简介
内容目录: JSONP应用 瀑布流布局 组合搜索 多级评论 tornado框架简介 JSONP应用 由于浏览器存在同源策略机制,同源策略阻止从一个源加载的文档或脚本获取或设置另一个源加载的文档的属性. ...
- HDU 4970 Killing Monsters
开始以为是线段树,算了一下复杂度也觉得能过...但是这题貌似卡了线段树... 具体做法: 对每一个塔,记录attack[l]+=d,attack[r+1]-=d;这样对于每个block,受到的伤害就是 ...
- mysql create routine 权限的一些说明
1.如果用户有create routine 权限那么他就可以创建procedure | function . 2.如果用户创建了procedure | function 那么mysql 会自动赋予它对 ...
- sqlserver系统表操作
查询表名中包含‘user’的方法Select * From sysobjects Where name like '%user%' 如果知道列名,想查找包含有该列的表名,可加上系统表syscolumn ...
- FAT16文件系统简介
有必要说明一下,以下对FAT16系统的介绍,很多都是参考文献.由于FAT16系统一般在U盘.MMC卡.SD卡以及一些小型存储设备上使用比较多,以后把这些小型存储设备统称为存储卡,这里仅局限于对存储卡的 ...
- Android中退出多个Activity的两个经典方法
这里介绍两种方法:一种把每个activity记住,然后逐一干掉:另一种思路是使用广播. 方法一.用list保存activity实例,然后逐一干掉 上代码: import java.util.Linke ...
- 【转】如何查看linux版本 如何查看LINUX是多少位
原文网址:http://sopace.blog.51cto.com/1227753/670526 如何得知自己正在使用的linux是什么版本呢,下面的几种方法将给你带来答案! 1. 查看内核版本命令: ...
- web api\ protobuf \formatter
9:50:20吴X2014/11/7 9:50:20 9:55:14吴X2014/11/7 9:55:14webapi实现protobuf吴X2014/11/7 9:56:29http://www.s ...