对于每一个点,可以找到他在x轴上的可行区域,这样的话就变为了对区间的贪心。

 #include<iostream>
#include<stdio.h>
#include<string.h>
#include<map>
#include<vector>
#include<set>
#include<stack>
#include<queue>
#include<algorithm>
#include<cmath>
#include<stdlib.h>
using namespace std;
#define MAX(a,b) (a > b ? a : b)
#define MIN(a,b) (a < b ? a : b)
#define MAXN 10000001
#define INF 1000000007
#define mem(a) memset(a,0,sizeof(a))
#define eps 1e-15 struct node{double s,t;}ma[];
double R;
int N; const int island_max=; void get_len(int index,double a,double b)
{
double temp = sqrt(R*R - b*b);
ma[index].s=a-temp;
ma[index].t=a+temp;
} int cmp(node a,node b)
{
if(a.t!=b.t)return (a.t < b.t);
return (b.s > a.s);
} int main()
{
int ca = ;
while(~scanf("%d%lf",&N,&R) && (N || R))
{
int i;
double a,b;
int flag = ;
for(i=;i<N;i++)
{
scanf("%lf %lf",&a,&b);
if(b<=R && !flag)
{
get_len(i,a,b);
}
else flag = ;
}
if(flag){printf("Case %d: -1\n",ca++);continue;}
sort(ma,ma+N,cmp);
double key = ma[].t;
int ans=;
for(i=;i<N;i++)
{
if(ma[i].s-key >eps)
{
key = ma[i].t;
ans ++;
}
}
printf("Case %d: %d\n",ca++,ans);
}
return ;
}

POJ1328Radar Installation(贪心)的更多相关文章

  1. poj1328Radar Installation 贪心

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 64472   Accepted: 14 ...

  2. 【贪心】POJ1328-Radar Installation

    [思路] 以每一座岛屿为圆心,雷达范围为半径作圆,记录下与x轴的左右交点.如果与x轴没交点,则直接退出输出“-1”.以左交点为关键字进行排序,从左到右进行贪心.容易知道,离每一个雷达最远的那一座岛与雷 ...

  3. POJ1328Radar Installation(区间点覆盖问题)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 68597   Accepted: 15 ...

  4. POJ 1328 Radar Installation 贪心 A

    POJ 1328 Radar Installation https://vjudge.net/problem/POJ-1328 题目: Assume the coasting is an infini ...

  5. Radar Installation(贪心)

    Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 56826   Accepted: 12 ...

  6. Radar Installation 贪心

    Language: Default Radar Installation Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 42 ...

  7. POJ1328 Radar Installation(贪心)

    题目链接. 题意: 给定一坐标系,要求将所有 x轴 上面的所有点,用圆心在 x轴, 半径为 d 的圆盖住.求最少使用圆的数量. 分析: 贪心. 首先把所有点 x 坐标排序, 对于每一个点,求出能够满足 ...

  8. Radar Installation(贪心,可以转化为今年暑假不ac类型)

    Radar Installation Time Limit : 2000/1000ms (Java/Other)   Memory Limit : 20000/10000K (Java/Other) ...

  9. poj 1328 Radar Installation(贪心+快排)

    Description Assume the coasting is an infinite straight line. Land is in one side of coasting, sea i ...

随机推荐

  1. 1742. Team building(dfs)

    1742 最小的是找联通块数 最大的找环 一个环算一个 其它的数各算一个 #include <iostream> #include<cstdio> #include<cs ...

  2. POJ 1113 凸包模板题

    上模板. #include <cstdio> #include <cstring> #include <iostream> #include <algorit ...

  3. bzoj2251

    以前看到这道题想到的是SA,做起来不是很美观 学了SAM之后,这题简直是随便搞 ..,'] of longint; s,sa,mx,w,fa:..] of longint; i,n,last,t:lo ...

  4. Dapper使用在WCF上总是说Service找不到

    原因是用Console Application 做宿主的时候,创建的时候默认是Client Profile 4 ,坑爹啊.改成Net framework 4 即可.

  5. HTML空格符号 &nbsp / &ensp / &emsp

      半角的不断行的空白格(推荐使用)    半角的空格    全角的空格

  6. BZOJ 3573 米特运输

    语文题... 原来除了hash还可以取对数啊orz #include<iostream> #include<cstdio> #include<cstring> #i ...

  7. jrtplib跨网络通讯NAT穿透问题解决方法

    前几篇文章讲了使用jrtplib在Android和pc端进行通讯的方法 在实际项目中,手机端和pc端一般不会在同一个子网内,两者之间联络可能要走路由器之类的NAT(网络地址转换 Network Add ...

  8. 【转】有趣的Autolayout示例-Masonry实现

    原文网址:http://tutuge.me/2015/05/23/autolayout-example-with-masonry/ 好久没有写Blog了,这段时间有点忙啊=.=本文举了3个比较有“特点 ...

  9. Jabber/XMPP协议与架构

    一.概述 由Jeremie Miller于1998年开始这个项目.Jabber是一个开放源码形式组织产生的网络实时通信协议,第一个公开版本于2000年5月发行.Jabber已经由IETF XMPP协议 ...

  10. Android Failure [INSTALL_FAILED_OLDER_SDK]

    今天编译工程发现 提示“ Failure [INSTALL_FAILED_OLDER_SDK]” 最后发现最小minSdkVersion 超过当前机器的版本,修改配置表中的minSdkVersion, ...