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<stdio.h> #include<math.h> int main () { int case1[1000]; int count=0; int i,j; int n,d; int temp1,temp2; int locax[1000],locay[1000]; int labx[1000],laby[1000]; int pointx,pointy; for(i=1;i<1000;i++) case1[i]=-2; while(scanf("%d%d",&n,&d),n||d) { count++; case1[count]=1; for(i=1;i<n+1;i++) { scanf("%d%d",&locax[i],&locay[i]); labx[i]=locax[i]-sqrt(d*d-locay[i]*locay[i]); laby[i]=locax[i]+sqrt(d*d-locay[i]*locay[i]); } for(i=1;i<n+1;i++) for(j=i+1;j<n+1;j++) if(laby[i]>laby[j]) { temp1=labx[i]; labx[i]=labx[j]; labx[j]=temp1; temp2=laby[i]; laby[i]=laby[j]; laby[j]=temp2; } pointx=labx[1]; pointy=laby[1]; for(i=2;i<n;i++) { if(laby[i]>d) {case1[count]=-1; break;} else if(labx[i]>pointy) {case1[count]++; pointx=labx[i]; pointy=laby[i]; } else if(labx[i]>pointx) pointx=labx[i]; } } i=1; while(case1[i]!=-2) { printf("Case %d: %d\n",i,case1[i]); i++;} getch(); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator