【codeforces】Radar Installation
2016-07-23 20:06
330 查看
别说话,看注释。
#include<stdio.h>//此题犯了一个超级二,又很可能被忽略而出现的问题 //输出-1的时候我竟然忘了Cace %d:格式了 / 大哭/哇/ #include<math.h> #include<algorithm> using namespace std; struct note { double front; double back; } s[1010]; bool judge(note a,note b) { if(a.front==b.front)//因为后面的圆包含在内的话前面的圆一定在内, //而后面圆不在内的话正好加一(这俩一定用一个雷达的,主要是和前面一个圆比较) return a.back>b.back; return a.front<b.front; } int main() { double d; int p=0,n; while(scanf("%d %lf",&n,&d),n||d) { double x,y,mark=1; double temp; for(int l=1; l<=n; l++) { scanf("%lf %lf",&x,&y); temp=d*d-y*y; if(temp<0||d<0)// mark=0; else if(mark) { s[l].front=x+sqrt((double)d*d-(double)y*y); s[l].back=x-sqrt((double)d*d-(double)y*y); } } if(!mark) { printf("Case %d: -1\n",++p); continue; } int sum=1; sort(s+1,s+n+1,judge); temp=s[1].front; for(int l=2; l<=n; l++) { if(temp<s[l].back) { sum++; temp=s[l].front; } } printf("Case %d: %d\n",++p,sum); } return 0; }
http://acm.hust.edu.cn/vjudge/contest/123357#problem/G
相关文章推荐
- Codeforces Round #197 (Div. 2)
- Codeforces Round #198 (Div. 1)
- Codeforces 405E Codeforces Round #238 (Div. 2)E
- Codeforces 407C Codeforces Round #239 (Div. 1)C
- CodeForces 449A - Jzzhu and Chocolate
- CodeForces 449 B. Jzzhu and Cities
- codeforces 618C. Constellation
- Codeforces Round #349 (Div. 2) - C
- Codeforces Round #361 (Div. 2)
- 7.13Codeforces Round #360 (Div. 2)
- Codeforces Round #363 (Div. 2)
- Codeforces Round #265 (Div. 2)
- Codeforces #310 div2 C. Case of Matryoshkas
- 状态压缩DP codeforces 244 Problem C. The Brand New Function 和 codeforces 165 E. Compatible Numbers
- codeforces 16 Problem E fish
- Codeforces Round332 部分题解
- CodeForces 603A_Alternative Thinking (DP)
- CodeForces 602B_Approximating a Constant Range_DP
- Codeforces round #247 for Div. 2
- Codeforces Round #246 (Div. 2)