思路没有错啊 为啥我这个写法就10分
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
using namespace std;
struct Point{
double x, y;
Point() {}
Point(double _x, double _y){
x = _x;
y = _y;
}
double len(){
return sqrt(1.0 * x * x + 1.0 * y * y);
}
//判断点是否重合
bool operator == (const Point& w) const{
return x == w.x && y == w.y;
}
Point operator - (const Point& w) const{
return Point(x - w.x, y - w.y);
}
Point operator + (const Point& w) const{
return Point(x + w.x, y + w.y);
}
double operator * (const Point&w) const{//点积
return x * w.x + y * w.y;
}
double operator ^ (const Point&w) const{//叉积
return x * w.y - y * w.x;
}
void print(){//打印当前坐标或者是向量
cout << x << ' ' << y << endl;
}
bool operator < (const Point&w) const{
if (x != w.x) return x < w.x;
else return y > w.y;
}
};
const int N = 1010;
int n, d;
Point p[N];
int main(){
cin >> n >> d;
for (int i = 1; i <= n; i ++){
cin >> p[i].x >> p[i].y;
if (p[i].y > d) {
cout << -1;
return 0;
}
}
sort(p + 1, p + 1 + n);
int cnt = 0, pos = -2000010;
Point dot = {pos, 0};
for (int i = 1; i <= n; i ++){
Point o = p[i] - dot;
if (o.x * o.x + o.y * o.y > d * d){
double x = sqrt(d * d - p[i].y * p[i].y);
dot.x = p[i].x + x;
cnt ++;
}
}
cout << cnt << endl;
}