计算出中轴能覆盖到某个点的极角范围,最大覆盖次数便是答案。ios
首先把中轴和点重合,此时中轴的角度为theta = atan(y/x),spa
而后以原点为圆心旋转点和抛物线相交求出之间的夹角,code
把x = a*y*y 化成极坐标下r cosθ = a *r *r (1 - cos2θ) ,解方程获得blog
极角范围应该为[theta-θ, theta+θ]。排序
有了极角范围,排序之后扫描线。事件
写的时候须当心的坑点:rem
1.theta-θ的范围可能超过[0, 2*pi],须要取余。string
2.取余之后有可能有end < begin的状况,须要在最左端手动添加事件点。it
3.端点是均可以包括的,当极角相同时,入点事件优先于出点事件。io
/********************************************************* * ------------------ * * author AbyssFish * **********************************************************/ #include<cstdio> #include<iostream> #include<string> #include<cstring> #include<queue> #include<vector> #include<stack> #include<map> #include<set> #include<algorithm> #include<cmath> #include<numeric> #include<climits> using namespace std; typedef long double ld; const int maxn = 3e4+1; double x[maxn], y[maxn]; inline ld sqr(ld x){ return x*x; } const ld DPI = acosl(-1)*2; typedef pair<ld,int> ev; #define fi first #define se second vector<ev> evs; #define pb push_back //#define LOCAL int main() { #ifdef LOCAL freopen("in.txt","r",stdin); #endif //cout<<remainder(-1,2); int n; double a; evs.reserve(maxn*3); while(~scanf("%d%lf",&n,&a)){ int i; for(i = 0; i < n; i++) scanf("%lf",x+i); for(i = 0; i < n; i++) scanf("%lf",y+i); ld theta, delta, r, be, ed; evs.clear(); for(i = 0; i < n; i++){ theta = atan2l(y[i],x[i]); r = sqrtl(sqr(x[i])+sqr(y[i])); delta = acosl( (-1+sqrtl(1+4*sqr(r)*sqr(a)))/(2*a*r) ); //if(delta < 0) delta = -delta; be = remainderl(theta-delta,DPI); ed = remainderl(theta+delta,DPI); if(be < 0) be += DPI; if(ed < 0) ed += DPI; evs.pb(ev(be,-1)); evs.pb(ev(ed,1)); if(ed < be){ evs.pb(ev(0,-1)); } } int ans = 0, cur = 0; sort(evs.begin(),evs.end()); for(vector<ev> ::iterator it = evs.begin(); it != evs.end(); it++){ cur -= it->se; //cout<<cur<<endl; ans = max(ans,cur); } printf("%d daze\n", ans); } return 0; }