您的位置:首页 > 其它

【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