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. 3月3日(4) Remove Duplicates from Sorted List

    原题 Remove Duplicates from Sorted List 有序单链表去重,delete 只能对指针起作用. /** * Definition for singly-linked li ...

  2. 基于BT协议的文件分发系统

    基于BT协议的文件分发系统构成:    1.一个Web服务器:保存着种子文件    2.一个种子文件:保存共享文件的一些信息(文件名,文件大小    ,Tracker服务器地址,torrent为后缀) ...

  3. C#inSSIDer强大的wifi无线热点信号扫描器源码

    一个完整的无线信号扫描工具源码,包含了从热点扫描到强度绘制以及信号变换曲线图.源码基于Managed Wifi实现基础功能,Managed Wifi也是开源项目,这个可以在本站搜索到. 指定网卡信号扫 ...

  4. 【原】去掉UltraGrid第三方控件中的Drag a column header here to group by that column

  5. zip生成

    生成zip文件官方网站:http://www.phpconcept.net/pclzip/ 用法一: 1 <?php 2     include_once('pclzip.lib.php'); ...

  6. JS获取图片实际宽高及根据图片大小进行自适应

    JS获取图片实际宽高,以及根据图片大小进行自适应  <img src="http://xxx.jpg" id="imgs" onload="ad ...

  7. php中的常用魔术方法总结

    以下是对php中的常用魔术方法进行了详细的总结介绍,需要的朋友可以过来参考下 常用的魔术方法有:__Tostring () __Call() __autoLoad() __ clone() __GET ...

  8. C#中linq

    class IntroToLINQ { static void Main() { // The Three Parts of a LINQ Query: // 1. Data source. ] { ...

  9. uploadify 上传

    本来想做一套上传公用的组建的,里面包含文件转码等功能,看来这些都只能后来一步一步加上了,先写下来... 1,引入脚本等 @{ Layout = null; } <!DOCTYPE html> ...

  10. 【转载】Powershell获取世纪互联Office365中所有用户的OWA时区

    get-mailbox -resultsize unlimited | Get-MailboxRegionalConfiguration | select Identity,TimeZone | wh ...