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 |
请高手帮忙看看!为什么老是wa?我不知道哪里错了啊!谢谢啦! #include "iostream" #include<math.h> using namespace std; struct node { int x,y; }; int _tmain(int argc, _TCHAR* argv[]) { int a[1000],l=0,ii; bool tag; int num=0; while(1){ int n,d; tag=false; num=0; node temp,now; cin>>n>>d; if(n==0&&d==0)break; if(d<=0){a[l++]=-1;} node *p=new node[n]; int i,j; for(i=0;i<n;i++) {cin>>p[i].x>>p[i].y;if(abs(p[i].y)>d&&d>0)tag=true;} if(tag==true){a[l++]=-1;continue;} if(d>0) { for(i=0;i<n;i++) { for(j=i+1;j<n;j++) if(p[i].x>p[j].x){ temp=p[i]; p[i]=p[j]; p[j]=temp; } } now=p[0]; j=n; int max1=1; int r,t,k=1; while(j!=0) { for(i=n-j;i<n;i++) if((p[i].x-now.x)>d*2) break; for(r=now.x;r<=p[i-1].x;r++) { for(t=n-j+1;t<i;t++) if((r-p[t].x)*(r-p[t].x)+p[t].y*p[t].y<=d*d) k++; if(max1<k)max1=k; k=1; } j=j-max1; max1=1; num++; now=p[n-j]; k=1; }; a[l++]=num;} }; for(ii=0;ii<l;ii++) cout<<"Case "<<ii+1<<": "<<a[ii]<<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