You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
39 lines
934 B
C++
39 lines
934 B
C++
#include <cstdio>
|
|
#include <cmath>
|
|
#include <algorithm>
|
|
#include <utility>
|
|
using namespace std;
|
|
pair<double, double> a[1005];
|
|
int main()
|
|
{
|
|
int n, d, T = 0, ans;
|
|
while (scanf("%d%d", &n, &d), n | d)
|
|
{
|
|
bool flag = false;
|
|
for (int i = 0, x, y; i < n; i++)
|
|
{
|
|
scanf("%d%d", &x, &y);
|
|
if (y > d)
|
|
flag = true;
|
|
else
|
|
{
|
|
double r = sqrt(d * d - y * y);
|
|
a[i].first = x - r;
|
|
a[i].second = x + r;
|
|
}
|
|
}
|
|
if (flag)
|
|
ans = -1;
|
|
else
|
|
{
|
|
sort(a, a + n);
|
|
ans = 1;
|
|
double r = a[0].second;
|
|
for (int i = 1; i < n; i++)
|
|
if (a[i].first > r)
|
|
ans++, r = a[i].second;
|
|
}
|
|
printf("Case %d: %d\n", ++T, ans);
|
|
}
|
|
return 0;
|
|
} |