Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
Re:终于过了 贴个AC代码In Reply To:终于过了 贴个AC代码 Posted by:09876543210 at 2014-03-13 17:40:45 这东西怎么看不到别人的回复啊 > #include<iostream> > #include<algorithm> > #include<cmath> > using namespace std; > struct point > { > double x1,x2; > }p[1005]; > bool cmp(point a,point b) > { > return a.x1<b.x1; > } > int main() > { > int n,r,i,t,end_flag,count; > double temp,x,y; > t=1; > while(cin>>n>>r) > { > if(n==0&&r==0) break; > end_flag=0; > count=1; > for(i=1;i<=n;i++) > { > cin>>x>>y; > if(y>r) end_flag=1; > p[i].x1=x-sqrt(r*r-y*y); > p[i].x2=x+sqrt(r*r-y*y); > } > cout<<"Case "<<t++<<": "; > if(end_flag) > { > cout<<-1<<endl; > continue; > } > sort(p+1,p+n+1,cmp); > temp=p[1].x2; > for(i=2;i<=n;i++) > { > if(p[i].x2<temp) temp=p[i].x2;//如果下一个区间在当前区间的内部。 > else if(p[i].x1>temp)//如果下一个区间不在当前区间内。 > { > count++; > temp=p[i].x2; > } > //不考虑两个区间有交集,此时雷达还是限制在原区间右端点。就这儿错了啊啊啊!!! > } > cout<<count<<endl; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator