POJ1328Radar Installation
http://poj.org/problem?id=1328
题的大意就是说在海里有小岛,坐标位置会给出,需要岸边的雷达覆盖所有的小岛,但雷达的覆盖范围有限,所以,需要最少的雷达覆盖所有的小岛,但若是有小岛没法被雷达给覆盖到,就输出-1;
这个题的话可以转化成区间问题就是看雷达的覆盖范围作为半径,A若是小岛的位置,根据雷达的覆盖范围只要不小于这个点的Y坐标,那个覆盖范围就是这个三角形的斜边,所以只要雷达位于1,2边上就可以覆盖到这个小岛
1 #include<cstdio> 2 #include<cstring> 3 #include<iostream> 4 #include<cstdlib> 5 #include<cmath> 6 #include<algorithm> 7 using namespace std ; 8 struct node 9 { 10 double x,y; 11 } s[10001]; 12 int cmp(struct node a,struct node b) 13 { 14 if(a.y< b.y) 15 return 1; 16 else return 0 ; 17 } 18 int main() 19 { 20 int n,d ; 21 int cnt = 1; 22 while(cin>>n>>d) 23 { 24 25 int flag = 0 ; 26 if(n == 0&&d == 0) break ; 27 double a,b ; 28 for(int i = 1 ; i <= n ; i++) 29 { 30 scanf("%lf %lf",&a,&b); 31 if(fabs(b) > d) 32 flag = 1 ; 33 s[i].x = a-sqrt(d*d-b*b); 34 s[i].y = a+sqrt(d*d-b*b); 35 } 36 cout<<"Case"<<' '<<cnt<<':'<<' '; 37 if(flag == 1) 38 cout<<"-1"<<endl ; 39 else 40 { 41 sort(s+1,s+1+n,cmp); 42 int sum = 1; 43 double zhizhen = s[1].y; 44 for(int i = 2 ; i <= n ; i++) 45 { 46 if(s[i].x>zhizhen) 47 { 48 sum++; 49 zhizhen = s[i].y; 50 } 51 } 52 53 cout<<sum<<endl; 54 } 55 cnt++; 56 } 57 return 0; 58 }
View Code
转载于:https://www.cnblogs.com/luyingfeng/p/3239360.html
POJ1328Radar Installation相关推荐
- POJ1328-Radar Installation
描述: Assume the coasting is an infinite straight line. Land is in one side of coasting, sea in the ot ...
- Installation failed with message Invalid File:(Application Installatino Failed)
导入一个demo 运行发现上图问题, Application Installation Failed 最后自己清理下工程就好了 参考方法: Click Build tab ---> Clean ...
- Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE
今天运行ecplise的时候 解决方法: Installation error: INSTALL_FAILED_INSUFFICIENT_STORAGE这个错误是表示,安卓系统存储空间不足了,无法再安 ...
- SAP Netweaver 7.4 SR2 Application Java Installation
记录一下SAP Netweaver 7.4 Support Release 2 Application Server Java的安装过程. 一.下载 写本文时,SAP Netweaver 7.4 SR ...
- 安装View Agent失败: The system must be rebooted before installation can continue
问题现象: 1.不能执行安装VMware View Agent程序 2.安装VMware View Agent失败,出现错误信息:The system must be rebooted before ...
- Error in install.packages : cannot remove prior installation of package
Error in install.packages : cannot remove prior installation of package 目录 Error in install.packages ...
- IBM Installation Manager 工具概述(转)
IBM Installation Manager 工具概述 IBM Installation Manager 是一款可运行在多种平台(如 IBM i. z/OS. Windows. Linux.Uni ...
- 计算机网络环境及应用系统的安装与调试(Computer network environment and application system installation and debugging)
计算机网络环境及应用系统的安装与调试(Computer network environment and application system installation and debugging) W ...
- 无线局域网安装与调试(Wireless LAN installation and commissioning)
无线局域网安装与调试(Wireless LAN installation and commissioning) 在校园内,无线局域网与现有校园网链接 无线统一网络AC功能描述 Configuratio ...
- Installation error: INSTALL_FAILED_VERSION_DOWNGRADE Android
我们在安装新的 APk 的时候.会出现 Installation error: INSTALL_FAILED_VERSION_DOWNGRADE 原因: 是由于 androidversionCode ...
最新文章
- CF498C Array and Operations(数论 + 最大流)
- VS2012简单的使用感受+插件推荐
- python引用传递的区别_python的值类型和引用类型及值传递和引用传递的区别
- boost::integer::gcd和boost::integer::lcm用法的测试程序
- 《源码分析转载收藏向—数据库内核月报》
- linux系统的安全机制有哪些内容,系统安全机制
- 某高校计算机系举办了一场,国家二级MS+OFFICE高级应用机试(操作题)-试卷25
- explode php 正则,php用preg_replace和explode将li列表分割成纯文本数组
- android webview getusermedia,如何从Webview中访问摄像头?
- cacti支持中文办法
- 实现自定义Sql 注入器
- 谷歌浏览器打开普通用户_谷歌浏览器为啥打开之后会是其他的浏览器的解决步骤...
- C++ 计算三角形面积
- Kerberos认证协议
- Echarts 柏拉图
- SQL 2014新功能介绍系列3 - 备份还原篇
- java客户端发消息到kafka
- 51单片机与ESP8266轻松上手Onenet(二)--onenet AT指令测试
- 容器技术-Docker 网络01-默认网络
- 安卓期末大作业——汉服社区(源码+任务书)