Radar Installation 分类: POJ 2015-06-15 19:54 8人阅读 评论(0) 收藏

时间:2022-08-29 23:27:33
Radar Installation
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 60120   Accepted: 13552

Description

Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the other. Each small island is a point locating in the sea side. And any radar installation, locating on the coasting, can only cover d
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.

Radar Installation                                                       分类:            POJ             2015-06-15 19:54    8人阅读    评论(0)    收藏

Figure A Sample Input of Radar Installations



Input

The input consists of several test cases. The first line of each case contains two integers n (1<=n<=1000) and d, where n is the number of islands in the sea and d is the distance of coverage of the radar installation. This is
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

For each test case output one line consisting of the test case number followed by the minimal number of radar installations needed. "-1" installation means no solution for that case.

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) 收藏的更多相关文章

  1. 迷之节约 分类: sdutOJ 最小生成树 2015-06-24 19&colon;10 10人阅读 评论&lpar;0&rpar; 收藏

    迷之节约 Time Limit: 1000ms Memory limit: 65536K 有疑问?点这里^_^ 题目描述 FF超级有钱,最近又买了n个(1 <= n <= 300)小岛,为 ...

  2. Hdu 1506 Largest Rectangle in a Histogram 分类: Brush Mode 2014-10-28 19&colon;16 93人阅读 评论&lpar;0&rpar; 收藏

    Largest Rectangle in a Histogram Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 ...

  3. 二分图匹配 分类: ACM TYPE 2014-10-01 19&colon;57 94人阅读 评论&lpar;0&rpar; 收藏

    #include<cstdio> #include<cstring> using namespace std; bool map[505][505]; int n, k; bo ...

  4. Can you find it&quest; 分类: 二分查找 2015-06-10 19&colon;55 5人阅读 评论&lpar;0&rpar; 收藏

    Description Give you three sequences of numbers A, B, C, then we give you a number X. Now you need t ...

  5. 菊花加载第三方--MBprogressHUD 分类: ios技术 2015-02-05 19&colon;21 120人阅读 评论&lpar;0&rpar; 收藏

    上次说到了网络请求AFN,那么我们在网络请求的时候,等待期间,为了让用户不认为是卡死或程序出错,一般都会放一个菊花加载,系统有一个菊花加载类叫UIProgressHUD.但是我今天要说的是一个替代它的 ...

  6. 滑雪 分类: POJ 2015-07-23 19&colon;48 9人阅读 评论&lpar;0&rpar; 收藏

    滑雪 Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 83276 Accepted: 31159 Description Mich ...

  7. Power Strings 分类: POJ 串 2015-07-31 19&colon;05 8人阅读 评论&lpar;0&rpar; 收藏

    Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64u Submit Status Practice POJ ...

  8. Network Saboteur 分类: 搜索 POJ 2015-08-09 19&colon;48 7人阅读 评论&lpar;0&rpar; 收藏

    Network Saboteur Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 10147 Accepted: 4849 Des ...

  9. 欧拉通路-Play on Words 分类: POJ 图论 2015-08-06 19&colon;13 4人阅读 评论&lpar;0&rpar; 收藏

    Play on Words Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 10620 Accepted: 3602 Descri ...

随机推荐

  1. Sql Server中Float格式转换字符串varchar方法(转)

    1.[Sql Server](70)  SELECT CONVERT(varchar(100), CAST(@testFloat AS decimal(38,2)))SELECT STR(@testF ...

  2. 这些HTML、CSS知识点,面试和平时开发都需要 No10-No11

    系列知识点汇总 1.基础篇 这些HTML.CSS知识点,面试和平时开发都需要 No1-No4(知识点:HTML.CSS.盒子模型.内容布局) 这些HTML.CSS知识点,面试和平时开发都需要 No5- ...

  3. 当碰到非ARC写的文件时在ARC环境下运行报错时解决办法

  4. easyui dialog

    <!--弹出“创建”窗口 --> <div id="dialog" class="easyui-dialog" title="创建机 ...

  5. PHP算法--将数字金额转换成大写金额

    最近在看一些PHP算法题,遇到一个将数字金额转换成大写金额的小算法题,这里贴出自己的一个例子. 注:这个小算法适用于10万以内的金额. <?php //$num = 12345.67; func ...

  6. 使用cisco SDM管理路由器

    实验拓扑: 实验目的:掌握如何通过SDM对路由器进行管理 实验需求:设置R1使其能够通过SDM进行管理 实验步骤: 步骤一:配置基本IP地址 步骤二:在R1上进行设置,使其能够通过SDM连接 R1(c ...

  7. T-SQL编程中的异常处理-异常捕获&lpar;catch&rpar;与抛出异常&lpar;throw&rpar;

    本文出处: http://www.cnblogs.com/wy123/p/6743515.html T-SQL编程与应用程序一样,都有异常处理机制,比如异常的捕获与异常的抛出,本文简单介绍异常捕获与异 ...

  8. 搭建lnmp教程

    LNMP指的是一个基于CentOS/Debian 上安装Nginx.PHP.MySQL.php.可以在独立主机上轻松的安装LNMP生产环境. 1 安装nginx 如果是一台新的服务器可直接安装(若以前 ...

  9. 高通平台的bootloader过程【转】

    ====================基本知识=======================LK是(L)ittle (K)ernel的缩写.高通平台android普遍采用LK作为其bootloade ...

  10. Spring boot学习笔记之&commat;SpringBootApplication注解

    @SpringBootApplication(exclude = SessionAutoConfiguration.class) public class BootReactApplication { ...