poj 1328 Radar Installation
来源:互联网 发布:验证域名所有权的方法 编辑:程序博客网 时间:2024/06/05 07:17
#include <cstdio>#include <algorithm>#include <cmath>#define MAX_N 1100using namespace std;pair<int,int> point[MAX_N];pair<double,double> arr[MAX_N];//inputint n,d;//answerint ans;int cnt = 1;void solve(){ ans = 1; //对点按左端点进行整理 sort(arr,arr + n); //for(int i = 0;i < n;i++){ // printf("%lf %lf",arr[i].first,arr[i].second); // } double spos = arr[0].second; //最左点的最右距离 for(int i = 1;i < n; i++){ if (arr[i].first - spos > 1e-5) { ans++; spos = arr[i].second; }else{ if (arr[i].second - spos < 1e-5) //下个岛屿的最右坐标小于当前最右可被侦测坐标 { spos= arr[i].second; } } }}int main(){ //freopen("C:\in.txt","r",stdin); while(scanf("%d%d",&n,&d) != EOF){ int ok = 1; if(!n && !d) break; for(int i = 0;i < n;i++){ scanf("%d%d",&point[i].first,&point[i].second); if(point[i].second > d) ok = 0; } //如果只有一个点 // if(n == 1) {printf("Case %d: 1\n",cnt++); continue;} //将坐标系上的点转为x轴上的区间 for(int i = 0;i < n;i++){ double x = point[i].first,y = point[i].second; double len = sqrt((double)(d*d - y*y)); arr[i].first = x - len; arr[i].second = x + len; } if(ok == 0){ printf("Case %d: -1\n",cnt++); continue; }else{ solve(); printf("Case %d: %d\n",cnt++,ans); } } return 0;}
0 0
- POJ 1328 "Radar Installation"
- POJ 1328 Radar Installation
- POJ 1328 Radar Installation
- POJ 1328 Radar Installation
- 1328 poj Radar Installation
- poj 1328 Radar Installation
- POJ 1328 Radar Installation
- poj 1328 Radar Installation
- poj 1328 Radar Installation
- POJ 1328 Radar Installation
- POJ 1328 Radar Installation
- POJ 1328 Radar Installation
- POJ 1328 Radar Installation
- POJ 1328 Radar Installation
- poj 1328 Radar Installation
- POJ-1328-Radar Installation
- poj 1328 Radar Installation
- POJ 1328 Radar Installation
- 【Unity 3D】学习笔记一:Label控件(标签控件)
- OCP 1Z0 051 163
- java文件中:sql语句中加参数:
- MyEclipse导入主题文件epf后xml及jsp等页面中点击标签之后显示灰白
- 跑数速度慢,修改参数
- poj 1328 Radar Installation
- 微信公众平台之CURL应用
- C++面试出现频率最高的30道题目(二)
- monkeyrunner内置uiautomator出错的原因
- 设计模式学习笔记
- HTML5中x-webkit-speech语音输入功能
- poj 3669Meteor Shower
- K-SVD与On-line dictionary learning
- <Lua程序设计(第二版)>书摘-11