Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## c语言写的，贴一下

Posted by MrGaozhong at 2018-09-14 16:05:32 on Problem 1328
```#include<stdio.h>
#include<math.h>
#include<string.h>

int main(){
int n,d;
int count=0;
while(scanf("%d%d",&n,&d)!=EOF&&(n!=0||d!=0)){
int i,j,x[1005],y[1005];
int pd = 0;
int sum=1;
double l[1005],r[1005],temp,b;
count++;
for(i=0;i<n;i++){
scanf("%d%d",&x[i],&y[i]);
if(y[i]>d) pd=1;
}
if(pd==1){
printf("Case %d: -1\n", count);
}
else {
for(i=0;i<n;i++){
l[i]=x[i]-(sqrt(d*d-y[i]*y[i]));
r[i]=x[i]+(sqrt(d*d-y[i]*y[i]));
}
for (i = 1; i < n; i++) {
for (j = 0; j < n - i; j++) {
if (l[j]>l[j + 1]) {
temp = l[j];
l[j] = l[j + 1];
l[j + 1] = temp;
temp = r[j];
r[j] = r[j + 1];
r[j + 1] = temp;
}
}
}
b=r[0];
for (i = 1; i < n; i++) {
if (l[i]>b) {
b = r[i];
sum++;
}
else if (r[i] < b) {
b = r[i];
}
}
printf("Case %d: %d\n",count,sum);
}
}
return 0;
}```

Followed by: