Radar Installation 分类: POJ 2015-06-15 19:54 8人阅读 评论(0) 收藏
Time Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 60120 | Accepted: 13552 |
Description
distance, so an island in the sea can be covered by a radius installation, if the distance between them is at most d.
We use Cartesian coordinate system, defining the coasting is the x-axis. The sea side is above x-axis, and the land side below. Given the position of each island in the sea, and given the distance of the coverage of the radar installation, your task is to write
a program to find the minimal number of radar installations to cover all the islands. Note that the position of an island is represented by its x-y coordinates.
Figure A Sample Input of Radar Installations
Input
followed by n lines each containing two integers representing the coordinate of the position of each island. Then a blank line follows to separate the cases.
The input is terminated by a line containing pair of zeros
Output
Sample Input
3 2
1 2
-3 1
2 1 1 2
0 2 0 0
Sample Output
Case 1: 2
Case 2: 1#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <cctype>
#include <queue>
#include <stack>
#include <algorithm>
using namespace std;
struct node//记录每个岛的安装雷达的范围
{
double L;
double R;
}point[1100];
bool cmp(node a,node b)//sort比较函数
{
return a.L<b.L;
}
int main()
{
int n,d;
int x,y;
int w=1;
bool flag;
while(scanf("%d %d",&n,&d))
{
if(n==0&&d==0)
{
break;
}
int top=0;
flag=true;
for(int i=0;i<n;i++)
{
scanf("%d %d",&x,&y);
if(d<y)//如果有不符合的记录
flag=false;
if(flag)
{
point[top].L=x-sqrt(d*d-y*y);
point[top].R=x+sqrt(d*d-y*y);
top++;
}
}
printf("Case %d: ",w++);
if(flag)
{
sort(point,point+top,cmp);
double ans=point[0].R;
int sum=1;
for(int i=1;i<top;i++)
{
if(point[i].L>ans)//如果按装的范围不能包括,就增加雷达的个数
{
ans=point[i].R;
sum++;
}
else if(point[i].R<ans)
{
ans=point[i].R;//雷达范围的更新
}
}
printf("%d\n",sum);
}
else
{
printf("-1\n");
}
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。
Radar Installation 分类: POJ 2015-06-15 19:54 8人阅读 评论(0) 收藏的更多相关文章
- 迷之节约 分类: sdutOJ 最小生成树 2015-06-24 19:10 10人阅读 评论(0) 收藏
迷之节约 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 FF超级有钱,最近又买了n个(1 <= n <= 300)小岛,为 ...
- Hdu 1506 Largest Rectangle in a Histogram 分类: Brush Mode 2014-10-28 19:16 93人阅读 评论(0) 收藏
Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 ...
- 二分图匹配 分类: ACM TYPE 2014-10-01 19:57 94人阅读 评论(0) 收藏
#include<cstdio> #include<cstring> using namespace std; bool map[505][505]; int n, k; bo ...
- Can you find it? 分类: 二分查找 2015-06-10 19:55 5人阅读 评论(0) 收藏
Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...
- 菊花加载第三方--MBprogressHUD 分类: ios技术 2015-02-05 19:21 120人阅读 评论(0) 收藏
上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ...
- 滑雪 分类: POJ 2015-07-23 19:48 9人阅读 评论(0) 收藏
滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...
- Power Strings 分类: POJ 串 2015-07-31 19:05 8人阅读 评论(0) 收藏
Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ ...
- Network Saboteur 分类: 搜索 POJ 2015-08-09 19:48 7人阅读 评论(0) 收藏
Network Saboteur Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10147 Accepted: 4849 Des ...
- 欧拉通路-Play on Words 分类: POJ 图论 2015-08-06 19:13 4人阅读 评论(0) 收藏
Play on Words Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 10620 Accepted: 3602 Descri ...
随机推荐
- spawn-fcgi
spawn-fcgi与PHP-FPM 前面介绍过,FastCGI接口方式在脚本解析服务器上启动一个或者多个守护进程对动态脚本进行解析,这些进程就是FastCGI进程管理器,或者称为FastCGI引擎. ...
- smarty -- foreach用法
{foreach},{foreachelse} 用于像访问序数数组一样访问关联数组 {foreach},{foreachelse} {foreach} is used to loop over an ...
- SQL isnull函数
select * from emp;
- winform 控件开发1——复合控件
哈哈是不是丑死了? 做了一个不停变色的按钮,可以通过勾选checkbox停下来,代码如下: 复合控件果然简单呀,我都能学会~ using System; using System.Collection ...
- JSP动作跳转页面的时候与根目录的问题
在JSP动作:<jsp:forward page="....">中,这个page属性所指定的页面要包含根目录的话,必须要用"/",不能够用" ...
- EXTJS 5 开发环境搭建
WEBstrom eclipse下载: http://www.eclipse.org/downloads/ spket 下载: 安装方式: http://wangke0611.iteye.com/bl ...
- java 网络编程(四)----UDP进阶篇聊天小程序
设计要求:单线程模式,客户端只发送数据,数据的来源为键盘录入,服务器端只接收数据,当客户端发送886的时候,客户端和服务器端都退出. 1. 发送端: public class Send impleme ...
- C++之: CDib类
头文件Cdib.h 源文件Cdib.cpp
- opencv常用数据结构之:IplImage
typedef struct_IplImage{ int nSize; //IplImage大小 int ID; //版本(=0) int nChannels; //大多 ...
- MapReduce之Writable相关类
当要在进程间传递对象或持久化对象的时候,就需要序列化对象成字节流,反之当要将接收到或从磁盘读取的字节流转换为对象,就要进行反序列化.Writable是Hadoop的序列化格式,Hadoop定义了这样一 ...