http://poj.org/problem?id=1328

题的大意就是说在海里有小岛,坐标位置会给出,需要岸边的雷达覆盖所有的小岛,但雷达的覆盖范围有限,所以,需要最少的雷达覆盖所有的小岛,但若是有小岛没法被雷达给覆盖到,就输出-1;

这个题的话可以转化成区间问题就是看雷达的覆盖范围作为半径,A若是小岛的位置,根据雷达的覆盖范围只要不小于这个点的Y坐标,那个覆盖范围就是这个三角形的斜边,所以只要雷达位于1,2边上就可以覆盖到这个小岛

 #include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std ;
struct node
{
double x,y;
} s[];
int cmp(struct node a,struct node b)
{
if(a.y< b.y)
return ;
else return ;
}
int main()
{
int n,d ;
int cnt = ;
while(cin>>n>>d)
{ int flag = ;
if(n == &&d == ) break ;
double a,b ;
for(int i = ; i <= n ; i++)
{
scanf("%lf %lf",&a,&b);
if(fabs(b) > d)
flag = ;
s[i].x = a-sqrt(d*d-b*b);
s[i].y = a+sqrt(d*d-b*b);
}
cout<<"Case"<<' '<<cnt<<':'<<' ';
if(flag == )
cout<<"-1"<<endl ;
else
{
sort(s+,s++n,cmp);
int sum = ;
double zhizhen = s[].y;
for(int i = ; i <= n ; i++)
{
if(s[i].x>zhizhen)
{
sum++;
zhizhen = s[i].y;
}
} cout<<sum<<endl;
}
cnt++;
}
return ;
}

POJ1328Radar Installation的更多相关文章

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

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

  2. poj1328Radar Installation 贪心

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

  3. POJ1328Radar Installation(贪心)

    对于每一个点,可以找到他在x轴上的可行区域,这样的话就变为了对区间的贪心. #include<iostream> #include<stdio.h> #include<s ...

  4. 【贪心】POJ1328-Radar Installation

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

  5. Poj1328Radar Installation雷达安装

    原题链接 经典贪心,转化为问题为,对于所有的区间,求最小的点数能使每个区间都至少有一个点. #include<iostream> #include<cstdio> #inclu ...

  6. mysql-5.6.34 Installation from Source code

    Took me a while to suffer from the first successful souce code installation of mysql-5.6.34. Just pu ...

  7. Create an offline installation of Visual Studio 2017 RC

    Create an offline installation of Visual Studio 2017 RC ‎2016‎年‎12‎月‎7‎日                             ...

  8. An error occurred during the installation of assembly 'Microsoft.VC90.CRT……的问题

    有一段时间没有用到AnkhSvn了,今天工作需要安装了一下.结果安装到一半就无法继续了,提示An error occurred during the installation of assembly ...

  9. "Installation failed !" in GUI but not in CLI (/usr/bin/winusb: line 78: 18265 Terminated )

    "Installation failed !" in GUI but not in CLI (/usr/bin/winusb: line 78: 18265 Terminated ...

随机推荐

  1. Excel中 设置使得每行的颜色不一样

        在编写测试案例的时候,众多的excel行看的眼睛花花的,这里给出一个小技巧,设置Excel的每行显示的颜色不一样,最终的效果如下:    具体操作:     1. Ctrl+A全选所有表格区域 ...

  2. 安装apk文件报waiting for device 时解决办法

    C:\Users\root>adb install d:\rry_0514.apkerror: more than one device and emulator- waiting for de ...

  3. .NET研发人员面试题(二)

    1.当使用new BB()创建BB的实例时,产生什么输出? public class AA { public AA() { PrintFields(); } public virtual void P ...

  4. Mongodb地理空间索引

    1.索引: 建立索引既耗时也费力,还需要消耗很多资源.使用{"bakckground":true}选项可以使这个过程在后台完成,同时正常处理请求.如果不包括background 这 ...

  5. [大牛翻译系列]Hadoop(20)附录A.10 压缩格式LZOP编译安装配置

    附录A.10 LZOP LZOP是一种压缩解码器,在MapReduce中可以支持可分块的压缩.第5章中有一节介绍了如何应用LZOP.在这一节中,将介绍如何编译LZOP,在集群做相应配置. A.10.1 ...

  6. WordPress 主题开发 - (一) 前言 待翻译

    原文出自: http://themeshaper.com/2012/10/22/the-themeshaper-wordpress-theme-tutorial-2nd-edition/ THE TH ...

  7. mysql在windows下支持表名大小写,lower_case_table_names

    windows下mysql默认是不支表名大小写的,也就是表名大小写不敏感.用phpmyadmin创建的驼峰式表名,全部被强制成小写.mysql表名大小写敏感的参数: lower_case_table_ ...

  8. ASP.NET Core 行军记 -----拔营启程

    ASP.NET MVC 6:https://docs.asp.net/en/latest/mvc/index.html ASP.NET Core :https://docs.asp.net/en/la ...

  9. 转字符驱动实例gpio

    概述: 字符设备驱动程序: 是按照字符设备要求完成的由操作系统调用的代码. 重点理解以下内容:  1. 驱动是写给操作系统的代码,它不是直接给用户层程序调用的,而是给系统调用的  2. 所以驱动要向系 ...

  10. Swift学习:闭包(Closures)

    /* 闭包(Closures)* 闭包是自包含的功能代码块,可以在代码中使用或者用来作为参数传值.* 在Swift中的闭包与C.OC中的blocks和其它编程语言(如Python)中的lambdas类 ...