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 ...
随机推荐
- 类似 select 选择框效果及美化
网上有各种各样的关于 select 选择框的美化,找了很多,并没有好的样式效果.所以就找了一个利用 ul li 做的类似 select 选择框的效果,不废话了,先上图,效果如下: 对于上图的箭头效果, ...
- Spring的2个思想
IOC:控制反转 反转:获取依赖对象的方式被反转了 控制反转是关于一个对象如何获取他所依赖的对象的引用,反转是指责任的反转. (1)对象实例化问题(Spring完成) 传统的依赖方式:程序员实例化 ( ...
- javascript 异常处理和事件处理
异常捕获 1.异常:当javascript引擎执行JS代码时,发生了错误,导致程序停止运行. 2.异常抛出:当异常产生,并且将这个异常生成一个错误信息 3.异常捕获: try{发生异常的代码块:}ca ...
- 常见http代码错误原因及处理
常见的HTTP错误可以分为以下四大类.每一大类又细分为很多类小错误.当您打不开网站或者打开网站报错时首先检查您输入的网站是否有误,检查网络是否有问题或者虚拟主机的DNS是否可以解析.确定没有问题时再看 ...
- PHP XDEBUG
PHP调试时,不得不提XDEBUG这个调试利器.学习PHP以来,几乎所有的问题我都利用它来解决. 首先关于如何安装,不在赘述,请自行google之.(需要特别注意的是:PHP5.2 和5.3 ,关于加 ...
- Android -- 自定义View小Demo,绘制钟表时间(一)
1,昨天刚看了hongyang大神推荐的自定义时钟效果(传动门:http://www.jianshu.com/users/a45d19d680af/),效果还是不错的,自己又在github上找了找,发 ...
- java多线程实现卖票小程序
package shb.java.demo; /** * 多线程测试卖票小程序. * @Package:shb.java.demo * @Description: * @author shaobn * ...
- 关闭VS实时调试器
到注册表删除以下2个项目就可以了 HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows NT/CurrentVersion/AeDebug/Debugger HK ...
- session讲解(二)——商城购物车练习
网上商城中“添加商品到购物车”是主要功能之一,所添加的商品都存到了session中,主要以二维数组的形式存储在session中,在这里我们将以买水果为例 第一:整个水果商品列表 <body> ...
- 链接库lib和dl的概念,加载方式的区别
使用LR进行基于windows socket协议做接口测试,只提供了lr_load_dll方法来动态加载动态链接库.之前学习阶段,对TinyXML的学习,使用的静态链接库,当时在程序调用的时候方法也跟 ...