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 ...
随机推荐
- 基于Qt实现的截图小程序
在最近做的行人检测项目中,由于需要训练分类器,而分类器的训练又需要有一个一定长宽的样本.为了方便样本的采集,因此实现了这样的一个截图程序.该程序的主要功能是加载视频到程序中,程序可以对视频进行播放.暂 ...
- ASP.NET的一般处理程序对图片文件的基本操作
以一个小项目为例: 验证码: public class VerifyCodeHelper { public VerifyCodeHelper() { this.ran = new Random(); ...
- 20145207《Java程序设计》第三周学习总结
前言 24号回来的,书看的差不多了,博客一直没写,求老师原谅呀!!!!!哈哈哈哈.博客我从今天开始补,对着书,一天最多能弄个两篇毕竟写这个东西挺费心思德,当然我做事慢也有关系.但是我会尽快的.老实讲, ...
- Java线程总结
在java中要想实现多线程,有两种手段,一种是继续Thread类,另外一种是实现Runable接口. 对于直接继承Thread的类来说,代码大致框架是: class 类名 extends Thread ...
- JS 实现中英文翻译
缺点就是还是会闪出中文,但是效果还行. var langPackage = { "主题":"Title", "下一页":"Next ...
- SQL Server XML基础学习之<7>--XML modify() 方法对 XML 数据中插入、更新或删除
/*------------------------------------------------------------------------------+ #| = : = : = : = : ...
- gulpfile.js
文件目录如上: 下载代码地址:https://github.com/lianbinghua/gulptest 切换目录:cd gulp 安装依赖包:npm install 编译文件:gulp或者gul ...
- C#与js的各种交互
今天遇到一个问题,查到不错的资料,放上来记录一下,以防忘记地址,算是我的笔记吧! 很多人都向在服务器端调用客户端的函数来操作,也就是在asp中调用javascript脚本中已经定义好的脚本函数.经过研 ...
- 动态时间规整(DTW) 转载
Dynamic Time Warping(DTW)诞生有一定的历史了(日本学者Itakura提出),它出现的目的也比较单纯,是一种衡量两个长度不同的时间序列的相似度的方法.应用也比较广,主要是在模板匹 ...
- 【ruby】快速安装gems的方法
在使用gem install ...的时候增加参数: --no-ri 可以不安装ri部分 --no-rdoc 可以不安装rdoc部分