#include using namespace std; #define LL long long #define LD long double #define PII pair #define VI vector #define VPII vector #define f first #define s second #define MP make_pair #define PB push_back #define SIZ(c) (int)(c).size() #define ALL(c) (c).begin(), (c).end() #define REP(i, n) for (int i = 0; i < (int)(n); i++) #define FOR(i, b, e) for (int i = (b); i <= (int)(e); i++) #define FORD(i, b, e) for (int i = (b); i >= (int)(e); i--) #define ll LL #define st f #define nd s #define mp MP #define pb PB #define eb emplace_back #define siz(c) SIZ(c) const int inf = 1e9 + 7; const LL INF = 1e18L + 7; #define sim template ostream & operator << (ostream &p, pair x) {return p << "<" << x.f << ", " << x.s << ">";} sim> auto operator << (ostream &p, n y) -> typename enable_if::value, decltype(y.begin(), p)>::type {int o = 0; p << "{"; for (auto c : y) {if (o++) p << ", "; p << c;} return p << "}";} void dor() {cerr << "\n";} sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);} sim, class s> void mini(n &p, s y) {if (p > y) p = y;} sim, class s> void maxi(n &p, s y) {if (p < y) p = y;} #ifdef DEB #define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__) #else #define debug(...) #endif #define I(x) #x " =", (x), " " #define punkt pair #define PLD pair const LD eps = 1e-9; struct prosta { LD A, B, C; prosta(LD a, LD b, LD c) { A = a; B = b; C = c; } }; punkt operator+ (punkt a, punkt b) { return MP(a.f + b.f, a.s + b.s); } punkt operator- (punkt a, punkt b) { return MP(a.f - b.f, a.s - b.s); } punkt operator* (punkt a, LD r) { return MP(a.f * r, a.s * r); } punkt operator* (LD r, punkt a) { return MP(a.f * r, a.s * r); } LD len(punkt a) { return sqrt(a.f * a.f + a.s * a.s); } LD dist(punkt a, punkt b) { return len(a - b); } punkt rzut(prosta a, punkt b) { return b - (b.f * a.A + b.s * a.B - a.C) / (a.A * a.A + a.B * a.B) * make_pair(a.A, a.B); } bool iszero(LD x) { return abs(x) < eps; } pair przedzial(punkt a, punkt x, LD r) { prosta p(a.s, -a.f, 0); punkt y = rzut(p, x); LD d = dist(x, y); if (r < d - eps) { return MP(0, MP(0, 0)); } LD diff = sqrt(r * r - d * d); LD d2 = len(y); if (iszero(d2 + len(a) - dist(y, a))) { d2 = -d2; } return MP(1, MP(d2 - diff, d2 + diff)); } int32_t main() { int n, r, a, b; scanf("%d%d%d%d", &n, &r, &a, &b); vector> pom; FOR(i, 1, n) { int x, y; scanf("%d%d", &x, &y); auto xx = przedzial(MP(a, b), MP(x, y), r); if(xx.f == 0)continue; debug(xx); pom.PB(MP(xx.s.f-1e-8, 1)); pom.PB(MP(xx.s.s+1e-8, -1)); } int res = 0; int sum = 0; sort(ALL(pom)); debug(""); for(auto i : pom) { sum += i.s; maxi(res, sum); debug(i, sum); } cout << res << endl; }