1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
| #include<cstdio> #include<cmath> #include<vector> #include<algorithm> using namespace std; double L,D; struct node{ double l,r; node(const double &x,const double &y){ double R=sqrt(D*D-y*y); this->l=max(x-R,0.0),this->r=min(x+R,L); return; } bool operator < (const node &x) const { return r==x.r?l>x.l:r<x.r; } }; vector<node> vil; int main(){ while(~scanf("%lf%lf",&L,&D)){ vil.clear(); int n,cnt=1; scanf("%d",&n); for(int i=0;i<n;++i){ double x,y; scanf("%lf%lf",&x,&y); vil.push_back(node(x,y)); } sort(vil.begin(),vil.end()); double pos=vil[0].r; for(int i=0;i<(int)vil.size();++i){ if(pos<=vil[i].r&&pos>=vil[i].l) continue; pos=vil[i].r,++cnt; } printf("%d\n",cnt); } return 0; }
|