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 |
看不出哪里有问题,求救啊#include "iostream" #include "cstdio" #include "algorithm" #include "cmath" using namespace std; struct area{ int x,y; double l,r; }island[1001]; int cmp(area x,area y){ return x.l<y.l; } int rid,least,temp_r,out; int account(int xx,int yy,int i){ if(rid<0) return 0; double temp=rid*rid-yy*yy; if(temp<0) return 0; temp=sqrt(temp); island[i].l=xx-temp; island[i].r=xx+temp; return 1; } int main(){ int count; int i,n=0; while(scanf("%d%d",&count,&rid) && (count || rid)){ for(i=0;i<count;i++){ scanf("%d%d",&island[i].x,&island[i].y); } for(i=0;i<count;i++){ out=account(island[i].x,island[i].y,i); if(!out) break; } if(!out) least=-1; else{ sort(island,island+count,cmp); i=0;least=0; while(i<count){ for(temp_r=island[i].r;island[i].l<=temp_r && i<count;i++) if(island[i].r<temp_r)temp_r=island[i].r; least++; } } printf("Case %d: %d\n",++n,least); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator