标签:
2 2 8 6 1 1 4 5 2 10 6 4 5 6 5
1 2
#include<stdio.h> #include<string.h> #include<math.h> #include<algorithm> #define max 10010 struct node { double left,right; }a[max]; bool cmp(node a,node b) { return a.left<b.left; } int main() { int N,n,w,h,x,r; scanf("%d",&N); while(N--) { int i=0,sum=0; scanf("%d%d%d",&n,&w,&h); while(n--) { scanf("%d%d",&x,&r); if(2*r<=h) continue; double len=sqrt(r*r-(h/2.0)*(h/2.0)); a[i].left=x-len; a[i++].right=x+len; } std::sort(a,a+i,cmp);//每个圆所能覆盖的范围的排序 double flagl=0.0,flagr=0.0; for(int k=0;k!=i;k++) { if(a[k].left<=flagl) { if(a[k].right>flagr) { flagr=a[k].right; } } else { flagl=flagr; sum++; if(flagl>=w)break; if(a[k].left>flagl + 1e-7 )break; k--; } } if(flagr<w)sum=0; else if(flagl<flagr) sum++; printf("%d\n",sum); } return 0; }
标签:
原文地址:http://www.cnblogs.com/tt-t/p/5022577.html