#include #include #include #include using namespace std; typedef long double ld; struct point { ld x, y; }; ld det(const point& a, const point& b) { return a.x * b.y - a.y * b.x; } point operator- (const point& a, const point& b) { return { b.x - a.x, b.y - a.y }; } ld dist(const point& a, const point& b) { point d = b - a; return sqrt(d.x * d.x + d.y * d.y); } ld dist(const point& a, const point& b, const point& p) { return abs(det(a - p, b - p) / dist(a, b)); } ld dot(const point& a, const point& b) { return a.x * b.x + a.y * b.y; } struct event { bool start; ld x; }; const ld eps = 1e-9; bool operator< (const event& a, const event& b) { return abs(a.x - b.x) < eps ? a.start > b.start : a.x < b.x; } int sgn(ld x) { return (x > 0) - (x < 0); } int main() { ios_base::sync_with_stdio(0); int n, r; point ab; cin >> n >> r >> ab.x >> ab.y; vector points(n); for (int i = 0; i < n; i++) { cin >> points[i].x >> points[i].y; } vector events; point zero = {0, 0}; for (point p : points) { ld d = dist(zero, ab, p); if (d > r) continue; ld s = sqrt(r*r - d*d); ld u = dist(zero, p); ld t = sqrt(u*u - d*d); int side = sgn(dot(ab, p)); ld span_s = (side || 1) * (t - s); ld span_t = (side || 1) * (t + s); // cerr << "point (" << p.x << ", " << p.y << ") " << span_s << ' ' << span_t << endl; events.push_back({ true, min(span_s, span_t) }); events.push_back({ false, max(span_t, span_s) }); } sort(events.begin(), events.end()); int counter = 0, result = 0; for (event e : events) { counter += e.start ? 1 : -1; result = max(result, counter); // cerr << "event " << (e.start ? "start" : "end") << " " << e.x << " : " << counter << ' ' << result << endl; } cout << result << endl; return 0; }