标签:style blog http color strong 数据
2 2 8 6 1 1 4 5 2 10 6 4 5 6 5
1 2
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cstdlib> 5 #include <vector> 6 #include <climits> 7 #include <algorithm> 8 #include <cmath> 9 #define LL long long 10 using namespace std; 11 struct point{ 12 int lt,rt; 13 }p[10010]; 14 bool cmp(const point &a,const point &b){ 15 return a.lt < b.lt; 16 } 17 int main(){ 18 int kase,n,w,h,i,x,r,ans,cur,v; 19 double temp; 20 bool flag; 21 scanf("%d",&kase); 22 while(kase--){ 23 scanf("%d %d %d",&n,&w,&h); 24 for(i = 0; i < n; i++){ 25 scanf("%d %d",&x,&r); 26 temp = r*r*1.0 - h*h/4.0; 27 if(temp > 0) temp = sqrt(temp); 28 else temp = 0; 29 p[i].lt = x - temp; 30 p[i].rt = x + temp; 31 } 32 sort(p,p+n,cmp); 33 ans = cur = 0; 34 flag = true; 35 while(cur < w){ 36 v = 0; 37 for(i = 0; i < n && p[i].lt <= cur; i++){ 38 v = max(v,p[i].rt); 39 } 40 if(v <= cur){flag = false;break;} 41 cur = v; 42 ans++; 43 } 44 printf("%d\n",flag?ans:0); 45 } 46 return 0; 47 }
标签:style blog http color strong 数据
原文地址:http://www.cnblogs.com/crackpotisback/p/3830471.html