Quoit Design
来源:互联网 发布:网易域名管理平台 编辑:程序博客网 时间:2024/05/24 16:15
http://acm.hdu.edu.cn/showproblem.php?pid=1007
Problem Description
Have you ever played quoit in a playground? Quoit is a game in which flat rings are pitched at some toys, with all the toys encircled awarded.
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.
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.
Input
The input consists of several test cases. For each 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.
Output
For each test case, print in one line the radius of the ring required by the Cyberground manager, accurate up to 2 decimal places.
Sample Input
20 01 121 11 13-1.5 00 00 1.50
Sample Output
0.710.000.75
YYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYY
最近点对问题,时间复杂度小于n^2;
#include<stdio.h>#include<string.h>#include<math.h>#include<algorithm>using namespace std;struct node{double x,y;}g[100008];int cmp(node a,node b){if(a.x==b.x)return a.y<b.y;return a.x<b.x;}double DIS(node x,node y){ return sqrt((x.x-y.x)*(x.x-y.x)+(x.y-y.y)*(x.y-y.y)); }int main(){int i,j,k,m,n;double sum,dis;while(scanf("%d",&m),m){for(i=0;i<m;i++)scanf("%lf%lf",&g[i].x,&g[i].y);sort(g,g+m,cmp);dis=1e10;for(i=0;i<m;i++){sum=1e10;for(j=i+1;j<m;j++){if(DIS(g[i],g[j])<sum)sum=DIS(g[i],g[j]);elsebreak;}if(sum<dis)dis=sum;}printf("%.2lf\n",dis/2);}return 0;}
- Quoit Design
- Quoit Design
- Quoit Design
- Quoit Design
- quoit Design
- HDU1007 Quoit Design
- 1007:Quoit Design
- HDOJ 1007 Quoit Design
- hdu 1007 Quoit Design
- zoj 2107 Quoit Design
- hdu 1007 Quoit Design
- hdu 1007 Quoit Design
- HDU-1007 Quoit Design
- hdoj_1007 Quoit Design
- hdu1007-Quoit Design
- hdu 1007 Quoit Design
- hdu 1007 Quoit Design
- hdu 1007 Quoit Design
- 连接数据库之独孤九剑
- 第十六天(C++代码重用)
- [2_3_nocows] DP=>Search+Memorial; Solution: Boundary=Whole-Inside
- 正则表达式
- ARM 开发板 与 PC机ubuntu系统 nfs 挂载
- Quoit Design
- Android下增加service和对应的AIDL
- 将工作环境迁移到 Linux
- ORACLE 常用日期函数
- 冒泡排序
- 在eclipse中误创建了超长的文件夹而引发的“无法删除指定的文件名无效或太长”问题
- Linux slab 分配器剖析
- SVG图片元素实现Tooltip提示功能
- JVM内存结构及java相关基础知识