| ||||||||||
| 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:楼主求解啊,数据过了却还是WAIn Reply To:Re:楼主求解啊,数据过了却还是WA Posted by:tomb at 2016-09-18 18:15:15 > #include<stdio.h>
> #include<iostream>
> #include<math.h>
> #include<algorithm>
> using namespace std;
> struct isl
> {
> int x,y;
> };
> struct rad
> {
> float sta,end;
> };
> bool cmp(rad a,rad b)
> {
> if(a.end<b.end)
> return true;
> else
> return false;
> };
> int main()
> {
> int n,d;
> rad rad[1002];
> isl isl[1002];
> int ymax=0;
> int i=0;
> int t=0;
> while(cin>>n>>d&&(n!=0||d!=0)&&n<=1000&&n>=1)
> {
> t++;
> for(i=0;i<n;++i)
> {
> cin>>isl[i].x>>isl[i].y;
> if(isl[i].y>ymax)
> {ymax=isl[i].y;}
> }
> cout<<" "<<endl;
> cout<<"Case"<<t<<":";
> if(ymax>d||d<0)
> {
> return -1;
> continue;
> }
> float len;
> for(i=0;i<n;++i)
> {
> len=sqrt(1.0*d*d-isl[i].y*isl[i].y);
> rad[i].sta=isl[i].x-len;
> rad[i].end=isl[i].x+len;
> }
> sort(rad,rad+n,cmp);
> int ans=0;
> for(i=0;i<n;)
> {
> int count=0;
> for(int j=i+1;j<n;++j)
> {
> if(rad[i].end>=rad[j].sta)
> {++count;}
> else
> {break;}
> }
> i+=count+1;
> ans++;
> }
> cout << ans << 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