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 ...
随机推荐
- zend optimizer在wamp的基础上安装
在用wampserver集成开发环境下,有时会碰到一些开源程序需要zend optimizer的支持,下面我用的wamp的版本是2.0,optimizer的版本是ZendOptimizer-3.3.3 ...
- Lintcode: Segment Tree Modify
For a Maximum Segment Tree, which each node has an extra value max to store the maximum value in thi ...
- JS练习 改变文本框状态
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- [原创] hadoop学习笔记:hadoopWEB监控
笔者安装单机版本 要想实现hadoopweb页面的监控,需要解决以下几个问题 1.关闭linux的防火墙:#service iptables stop 2.将linuxSE设置为disabled:#v ...
- ajax测试异步提交
今天测试了$.ajax()方法: $("a").click(function(){ $.ajax({ url:"MyJsp.jsp&qu ...
- java mybatis 框架下多种类型的参数传入到xml问题
由于公司要求,最近从.net向java 转,然后过程中遇到各种奇葩问题,特在此随记一番. 场景:一个方法中有两个参数,一个List的集合,一个int 类型的参数,最初我在xml的sql参数,无论定义成 ...
- python添加tab键提示
新建一个tab.py脚本 #!/usr/bin/python import sys import readline import rlcompleter import atexit import os ...
- jquery选项卡切换
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding= ...
- [Ubuntu] google chrome乱码
问题描述 ubuntu14.04,之前google chrome一直都是好好的,升级过相关软件,之后就是乱码了,如图 经过google的努力,找到解决方法,原因未明. 解决方案 sudo /etc/f ...
- 【PyQuery】PyQuery总结
pyquery库是jQuery的Python实现,可以用于解析HTML网页内容, 官方文档地址是:http://packages.python.org/pyquery/. 二.使用方法 ? 1 fro ...