题目链接:http://acm.nyist.net/JudgeOnline/problem.php?pid=12
#include<cstdio>
#include<cmath>
#include<algorithm>
using namespace std;
struct point{
double left,right;
}a[10001];
bool cmp(point b,point c){
return b.left<c.left;
}
int main(){
int ncase,n,len,wight;
double w;
scanf("%d",&ncase);
while(ncase--){
int flag=1,count=0;
scanf("%d%d%d",&n,&len,&wight);
w=wight/2.000000;
for(int i=0;i<n;i++){
int xi,ri;
double temp;
scanf("%d%d",&xi,&ri);
temp=sqrt(ri*ri-w*w);
if(temp>0){
a[i].left=xi-temp;
a[i].right=xi+temp;
}
}
sort(a,a+n,cmp);
double max=0;
double sum=0;
while(sum<len){
max=0;
for( int i=0;i<n&&a[i].left<=sum;i++){
if(a[i].right-sum>max)
max=a[i].right-sum;
}
if(max==0){
flag=0;
break;
}
else{
count++;
sum+=max;
}
}
if(flag)
printf("%d\n",count);
else
printf("0\n");
}
}