#include using namespace std; #define st first #define nd second template T K(T a) {return a * a;} #define K(a) K(1LL * (a)) typedef long long ll; typedef long double ld; const ld eps = 1e-12; struct P { ld x, y; ld dot(P b) {return x * b.x + y * b.y;} ld len() {return sqrt(K(x) + K(y));} P scaleTo(ld to) {return *this * (to / len());} ld dist(P & b) { return (*this - b).len();} P rotate90() { return P{-y, x};} ld angle() {return atan2(y, x);} P rotate(ld ang) { ld c = cos(ang), s = sin(ang); return P{x * c - y * x, x * s + y * c}; } P operator +(const P &rhs) const { return P{x + rhs.x, y + rhs.y}; } P operator -(const P &rhs) const { return P{x - rhs.x, y - rhs.y}; } P operator *(const ld c) const { return P{x * c, y * c}; } /*bool operator < (P he) { return make_pair(x, y) < make_pair(he.x, he.y);} bool below (P a, P b) { return (b - a) * (*this - a) <= 0;} P apo_in(P b, ld ratio) { return (*this + b * ratio) / (1 + ratio); } P apol_out(P b, ld ratio) { return (*this - b * ratio) / (1 - ratio); }*/ }; struct L3 { ld a, b, c; //L3 () {} //L3(ll _a, ll _b, ll _c) : a(_a), b(_b), c(_c) {} L3 fix() { assert(abs(b) > eps || abs(a) > eps); ll g = (b > eps || (abs(b) < eps && a > eps)) ? 1 : -1; return L3{a / g, b / g, c / g}; } ld dist(P he) { return abs(a * he.x + b * he.y + c) / sqrt(K(a) + K(b)); } P dir() { return P{b, -a};} P normal() { return P{a, b}; } P project(P he) { ld den = K(a) + K(b); return P{(b * (b * he.x - a * he.y) - a * c) / den, (a * (a * he.y - b * he.x) - b * c) / den }; } }; struct Circle { P o; ld r; vector

inter(L3 he) { P prim = he.project(o); ld d = prim.dist(o); if (d >= r + eps) return vector

{}; if (abs(d - r) <= eps) return vector

{prim}; P vec = he.dir().scaleTo(sqrt(K(r) - K(d))); return vector

{prim + vec, prim - vec}; } }; L3 toL3(P one, P two) { ld a = two.y - one.y; ld b = one.x - two.x; return L3{a, b, -(a * one.x + b * one.y)}.fix(); } int main() { ios_base::sync_with_stdio(0); cin.tie(0); int n; ld r, a, b; bool sw = 0; cin >> n >> r >> a >> b; if (b > a) { sw = 1; swap(a, b); } L3 l = toL3(P{0., 0.}, P{a, b}); vector> intervals; for (int i = 0; i < n; ++i) { ld x, y; cin >> x >> y; if (sw) { swap(x, y); } Circle c{P{x, y}, r}; auto vec = c.inter(l); if (vec.empty()) { continue; } if (vec.size() == 1) { intervals.push_back({vec[0], vec[0]}); } else { intervals.push_back({vec[0], vec[1]}); } } /*for (int i = 0; i < intervals.size(); ++i) { cout << "(" << intervals[i].st.x << ", " << intervals[i].st.y << ") --- " << "(" << intervals[i].nd.x << ", " << intervals[i].nd.y << ") \n"; }*/ vector> event; for (auto &i : intervals) { if (i.st.x > i.nd.x) { swap(i.st, i.nd); } event.push_back({i.st.x, 1}); event.push_back({i.nd.x, -1}); } sort(event.begin(), event.end(), [](auto e1, auto e2) { if (abs(e1.st - e2.st) < eps) { return e1.nd > e2.nd; } return e1.st < e2.st; }); int res = 0; int cur = 0; for (auto e : event) { cur += e.nd; res = max(res, cur); } cout << res << "\n"; }