poj1328Radar Installation--贪心
来源:互联网 发布:淘宝免费促销模板 编辑:程序博客网 时间:2024/06/09 23:45
代码如下:
#include <cstdio>#include <iostream>#include <cstring>#include <cctype>#include <cmath>#include <algorithm>#include <queue>#include <stack>#include <set>#include <map>#include <cstdlib>#include <vector>#define ll long long#define maxn 1010using namespace std;double x[maxn], y[maxn];int main(){ int n, d, a, b, w = 1; while ( ~scanf( "%d%d", &n, &d) && ( d || n)){ bool fg = false; for ( int i = 0; i < n; i++){ scanf( "%d%d", &a, &b); if ( b > d || b < 0) fg = true; if ( !fg){ x[i] = a - sqrt( 1.0 * d * d - b * b); y[i] = a + sqrt( 1.0 * d * d - b * b); } } printf( "Case %d: ", w++); if ( fg){ printf( "-1\n"); } else{ for ( int i = 0; i < n - 1; i++){ int k = i; for ( int j = i + 1; j < n; j++){ if ( y[k] - y[j] > 1e-8){ k = j; } else if ( fabs( y[j] - y[k]) < 1e-8 && x[j] - x[k] > 1e-8){ k = j; } } if ( k != i){ swap( x[i], x[k]); swap( y[i], y[k]); } } double z = y[0]; int c = 1; for ( int i = 1; i < n; i++){ if ( x[i] - z > 1e-8){ z = y[i]; c++; } } printf( "%d\n", c); } } return 0;}
0 0
- poj1328Radar Installation(贪心)
- poj1328radar installation 【贪心】
- poj1328Radar Installation 贪心
- poj1328Radar Installation--贪心
- POJ1328Radar Installation(贪心)
- poj1328Radar Installation (贪心)
- poj1328Radar Installation(贪心+区间选择)
- POJ1328Radar Installation(贪心,区间)
- poj1328Radar Installation(贪心—区间选点)
- poj1328Radar Installation
- poj1328Radar Installation
- poj1328Radar Installation
- POJ1328Radar Installation
- POJ1328Radar Installation
- poj1328Radar Installation解题报告
- POJ1328 Radar Installation 贪心
- Radar Installation 贪心 hoj
- 1328 Radar Installation 贪心
- Application.mk语法解释
- 汇编知识
- 基于python的Lasagne包对minist的代码解读
- spark on yarn 的那些坑
- 万年历程序例题(农历阴历转换)
- poj1328Radar Installation--贪心
- Rotation Vector CV Crosscheck
- UC/OS II时间片轮转法调度修改
- poj-3320-Jessica's Reading Problem
- ios开发网址总结
- Tomcat设置默认启动项目及Java Web工程设置默认启动页面
- Hibernate的N+1查询及解决
- LeetCode:N-Queens
- HDU3068 最长回文 manacher模板