Radar Installation(1328)
来源:互联网 发布:浙江义乌淘宝大学 编辑:程序博客网 时间:2024/06/07 20:38
大致题意:给定一些点和固定半径的圆, 圆心都在x轴上, 问至少要多少个圆才能将上面的点都包括在里面
方法:按照能包括这些点左边的圆心排序,然后从左向右贪心。
#include <cstdio>#include <cstring>#include <iostream>#include <algorithm>#include <cmath>using namespace std;struct s{ double x, y, o; bool operator < (const s &a) const{ return o < a.o; }}pp[1100];int n, m, st;bool vis[1100];bool judge(){ int i; for(i = 1; i <= n; i++) if(!vis[i]){ st = i; return true; } return false;}int main(){ int i, cas; cas = 0; while(scanf("%d%d", &n, &m) == 2){ if(!n && !m) break; memset(vis, 0, sizeof(vis)); int flag = 0; for(i = 1; i <= n; i++){ scanf("%lf%lf", &pp[i].x, &pp[i].y); if(pp[i].y > m) flag = 1; pp[i].o = pp[i].x + sqrt(m*m-pp[i].y*pp[i].y); } printf("Case %d: ", ++cas); if(flag){ printf("-1\n"); continue; } sort(pp+1, pp+1+n); int ans = 0; while(judge()){ ans ++; vis[st] = 1; for(i = st+1; i <= n; i++){ if((pp[i].x-pp[st].o)*(pp[i].x-pp[st].o) + pp[i].y*pp[i].y <= m*m) vis[i] = 1; } } printf("%d\n", ans); } return 0;}
0 0
- Radar Installation(1328)
- Radar Installation(poj)1328
- Radar Installation(POJ-1328)
- Radar Installation(POJ 1328)(贪心)
- POJ 1328 - Radar Installation(贪心)
- POJ 1328 Radar Installation(贪心)
- ZOJ-1360(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 (贪心)
- 工作二总结——objective-C中sqlite3数据库的处理(其三) sqlite3数据库事务的使用
- unity3d技能冷却cd(第一篇)
- C#——列表框(listbox)的体验添加
- autocomplete使用手册
- 【概率论水题】COGS1487麻球繁衍
- Radar Installation(1328)
- 今年第几天?
- NSPredicate
- 存储过程
- 第十一周上机项目二(1)求最大公约数
- 第十一周项目一(3)
- destoon调用discuz论坛中带图片帖子的方法
- STM32学习笔记 2014年11月6日下午
- 第十一周项目一——星号图