Radar Installation
1 #include<cstdio> 2 #include<cstdlib> 3 #include<cstring> 4 #include<algorithm> 5 #include<math.h> 6 7 const int MAXN=10000; 8 using namespace std; 9 struct node 10 { 11 double x1,x2; 12 } p[MAXN]; 13 bool cmp(node a,node b) 14 { 15 return a.x2<b.x2; 16 } 17 int main() 18 { 19 int n,m,ii=0; 20 double x,y; 21 while(scanf("%d%d",&n,&m)) 22 { 23 ii++; 24 if(n==0&&m==0) break; 25 int flag=0; 26 for(int i=0; i<n; i++) 27 { 28 scanf("%lf%lf",&x,&y); 29 if(fabs(y)>m) flag=1; 30 double c=sqrt(m*m-y*y); 31 p[i].x1=x+c; 32 p[i].x2=x-c; 33 } 34 if(flag==1) 35 { 36 printf("Case %d: %d\n",ii,-1); 37 continue; 38 } 39 sort(p,p+n,cmp); 40 double c=p[0].x1; 41 int t=1; 42 for(int i=1; i<n; i++) 43 { 44 if(p[i].x1<c) 45 { 46 c=p[i].x1; 47 } 48 else if(p[i].x2>c) 49 { 50 t++; 51 c=p[i].x1; 52 } 53 } 54 printf("Case %d: %d\n",ii,t); 55 } 56 return 0; 57 }