poj 1328
来源:互联网 发布:java字典表 编辑:程序博客网 时间:2024/05/22 05:58
2014/12/10
太渣,错了很多次。。贪心贪吧,贪吧。
一个个遍历算半径会有精度问题,要一开始就算出点的所在的左右半径中心。。
#include<stdio.h>#include<string.>#include<algorithm>#include<math.h>using namespace std;double d;struct node{double l,r;}s[1005];int cmp(node a,node b){return a.l<b.l;}int main(){int n;int k = 1;double a,b;while(~scanf("%d%lf",&n,&d)&&n&&d){int temp = 0;for(int i =0 ;i < n; i++){scanf("%lf%lf",&a,&b);if(fabs(b) > d){temp = 1;}s[i].l = a-sqrt(d*d-b*b);s[i].r = a+sqrt(d*d-b*b);}if(temp){printf("Case %d: -1\n",k++);continue;}sort(s,s+n,cmp); double point ; int cnt = 1; point = s[0].r;for(int i = 1;i < n; i++){if(point < s[i].l){ point = s[i].r; cnt++;}else if(point > s[i].r){point = s[i].r;}}printf("Case %d: %d\n",k++,cnt);}return 0;}
0 0
- poj 1083 & poj 1328
- POJ 1328
- poj 1328
- poj 1328
- POJ 1328
- poj 1328
- POJ 1328
- POJ 1328
- POJ--1328
- poj-1328
- POJ 1328
- POJ 1328
- poj 1328
- poj 1328
- POJ 1328
- POJ 1328
- POJ 1328
- poj 1328
- 牢骚 android开发
- Junit单元测试hibernate时解决多次创建SessionFactory
- Ceilometer项目源码分析----ceilometer-agent-compute服务的初始化和启动
- 面向对象来做一个迷宫游戏(努深刻学习面向对象技术以及面向对象的设计模式)
- eclipse自动补全
- poj 1328
- 我要码码码
- hibernate.cfg.xml配置信息
- eclipse 插件easyshell
- 做一个当日内容的列表
- ASP脚本语言的19个基本技巧使用
- ASP Session对象的集合以及属性方法事件
- ASP SCRIPT: 计数器(使用GrapShot组件)
- 学以致用 驳“ASP低能论”