晕死了,就是过不了,换了中思想还是过不了,,不清楚是怎么回事,寒假刷题还是不怎么样呀,
没什么紧张感,但是我会坚持的.
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
struct Point
{
int x;
int y;
bool operator < (Point t) const
{
return x < t.x;
}
}p[1111], r;
int N, d;
double getx(Point p)
{
return sqrt(double(d * d) - double(p.y * p.y));
}
int Solve()
{
int cunt = 1;
double temp = getx(p[0]);
double left = p[0].x - temp;
double right = p[0].y + temp;
double f_left, f_right;
for (int i = 1; i < N; i++)
{
temp = getx(p[i]);
f_left = p[i].x - temp;
f_right = p[i].x + temp;
if (f_left > left)
{
left = f_left;
if (f_right < right)
{
right = f_right;
}
else
{
continue;
}
}
else
{
left = f_left;
right = f_right;
cunt++;
}
}
return cunt;
}
int main()
{
int cnt = 1;
while (scanf("%d %d", &N, &d) && N | d)
{
int flag = 1;
for (int i = 0; i < N; i++)
{
scanf("%d %d", &p[i].x, &p[i].y);
if (p[i].y > d || p[i].y < 0)
{
flag = 0;
}
}
printf("\n");
printf("Case %d: ", cnt++);
if (flag == 0)
{
printf("-1\n");
}
else
{
sort(p, p + N);
// Print();
int ans = Solve();
printf("%d\n", ans);
}
}
// system("pause");
return 0;
}