对于每一个点,可以找到他在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. 宏buf_pool_struct

    typedef struct buf_pool_struct buf_pool_t; /** @brief The buffer pool structure. NOTE! The definitio ...

  2. Qt之自定义界面(添加自定义标题栏)

    简述 通过上节内容,我们实现了自定义窗体的移动,但是我们缺少一个标题栏来显示窗体的图标.标题,以及控制窗体最小化.最大化.关闭的按钮. 自定义标题栏后,所有的控件我们都可以定制,比如:在标题栏中添加换 ...

  3. Windows Live Writer测试插件

    这是用WLW写的,测试 这是图片: 这是地图: 这是代码: 一会重发

  4. (转)Linux: su sudo sudoer

    http://zebralinux.blog.51cto.com/8627088/1369301 日常操作中为了避免一些误操作,更加安全的管理系统,通常使用的用户身份都为普通用户,而非root.当需要 ...

  5. Swift compile slow 编译慢问题

    http://stackoverflow.com/questions/29707622/bizarre-swift-compiler-error-expression-too-complex-on-a ...

  6. JavaScript学习笔记(备忘录)

    ===运算符 判断数值和类型是否相等.如: console.log('s'==='s') //输出trueconsole.log('1'===1) //输出false

  7. delphi中计算指定日期是该月第几周的函数

      NthDayOfWeek 计算并返回指定日期是该月第几周 Unit:DateUtils function NthDayOfWeek(const AValue: TDateTime): Word; ...

  8. 【转载】ACM总结——dp专辑

    感谢博主——      http://blog.csdn.net/cc_again?viewmode=list       ----------  Accagain  2014年5月15日 动态规划一 ...

  9. Android中不混淆类中函数

    情况一:混淆不同的函数aTest.bTest -keep class com.zony.Test { void aTest(byte[], int, int); void bTest(String, ...

  10. Jedis的Sharded源代码分析

    概述 Jedis是Redis官方推荐的Java客户端,更多Redis的客户端可以参考Redis官网客户端列表.当业务的数据量非常庞大时,需要考虑将数据存储到多个缓存节点上,如何定位数据应该存储的节点, ...