1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <string>
#include <iostream>
using
namespace std;
struct
Node
{
double
l; double
r;
}node[11111];
double
gao( double
r, double
x )
{
return
sqrt (r*r-x*x);
}
int
cmp( const
Node &a, const
Node &b)
{
return
a.r<b.r;
}
int
main()
{
int
n,d;
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
double
x,y; int
sum=1;
while ( scanf ( "%d%d" ,&n,&d),n||d){
int
jiba=0;
for ( int
i=0;i<n;i++){
scanf ( "%lf%lf" ,&x,&y);
if (y>d||d<0||y<0){
jiba=1; continue ;
}
double
len=gao(d,y);
double
l,r;
l=x-len;r=x+len;
node[i].l=l;node[i].r=r;
}
sort(node,node+n,cmp);
double
ret[11111];
int
ans=0;
for ( int
i=0;i<n;i++){
int
flag=0;
for ( int
j=0;j<ans;j++){
if (node[i].l<=ret[j]&&node[i].r>=ret[j]){
flag=1; break ;
}
}
if (!flag){
ret[ans++]=node[i].r;
}
}
printf ( "Case %d: " ,sum++);
if (jiba)
printf ( "-1\n" );
else
printf ( "%d\n" ,ans);
}
return
0;
}
|