UVALIVE 2519 Radar Installation 区间选点问题
来源:互联网 发布:京东mac客户端下载 编辑:程序博客网 时间:2024/04/30 04:07
#include <map>#include <set>#include <list>#include <cmath>#include<cctype>#include <ctime>#include <deque>#include <stack>#include <queue>#include <cstdio>#include <string>#include <vector>#include <cstdlib>#include <cstring>#include <iostream>#include <algorithm>#define LL long long#define PI 3.1415926535897932626using namespace std;#define MAXN 1005int gcd(int a, int b){return a % b == 0 ? b : gcd(b, a % b);}int N,R;bool vis[MAXN];struct node{ double l,r; friend bool operator <(const node &a, const node &b) { if (a.r==b.r)return a.l<b.l; return a.r<b.r; }}src[MAXN];int main(){ //freopen("sample.txt","r",stdin); int kase=1; while (scanf("%d%d",&N,&R)!=EOF) { if (N==0 && R==0) break; bool found=false; int x,y; for (int i=0;i<N;i++) { scanf("%d%d",&x,&y); if (y>R) found=true; double t=sqrt((double)(R*R-y*y)); src[i].l=x-t; src[i].r=x+t; } printf("Case %d: ",kase++); if (found) printf("-1\n"); else { sort(src,src+N); memset(vis,false,sizeof(vis)); int ans=0; double tmp; for (int i=0;i<N;i++) { if (vis[i]) continue; ans++; int j=i+1; tmp=src[i].r; while (j<N){ if (!vis[j] && src[j].l<=tmp) vis[j]=true; j++; } } printf("%d\n",ans); } } return 0;}
0 0
- UVAlive 2519 Radar Installation (区间选点问题)
- UVALIVE 2519 Radar Installation 区间选点问题
- uvalive 2519 - Radar Installation(区间选点问题)
- UVALive 2519 Radar Installation 雷达扫描 区间选点问题
- UVALive - 2519 Radar Installation(区间选点问题)
- POJ1328 Radar Installation (区间选点问题,贪心)
- Radar Installation(区间选点)
- Radar Installation(贪心。 区间选点)
- [ACM] POJ 1328 Radar Installation (贪心,区间选点问题)
- poj 1328 Radar Installation 【贪心】【区间选点问题】
- POJ - 1328 Radar Installation (贪心,区间选点问题)
- POJ 1328 Radar Installation(贪心+区间选点问题)
- POJ 1328 Radar Installation (贪心,区间选点问题)
- (贪心,区间选点问题) Radar Installation POJ 1328
- poj 1328Radar Installation(uvaoj 2519)区间选点
- POJ1328 Radar Installation 【贪心·区间选点】
- POJ1328 Radar Installation 【贪心·区间选点】
- POJ-Radar Installation-贪心-区间选点
- PHP学习实例—1(简易计算器)
- C++智能指针--weak_ptr
- 单例模式
- php之foreach遍历数组
- HDU 1020 Encoding 控制字符串的输出
- UVALIVE 2519 Radar Installation 区间选点问题
- iframe与form结合,进行局部刷新
- 《剑魂之刃》游戏破解
- C++智能指针--shared_ptr
- 每个开发者都应该有一款自己的App
- HDU 1041 Computer Transformation 大数递推
- 设计模式之建造者模式 c++实现和详细分析
- C++智能指针--unique_ptr
- 一道简单的C程序--考考你