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 |
难道怎是rpwt,这样为什么会wa?看不出来是哪里错了。 重新写了个没用排序的,就过了。 好诡异呀! 大牛帮看下。 //------------------------------------------ #include<stdio.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int*)b-*(int*)a; } int main() { int m,n,p=0,a[51],b[1001]; while(scanf("%d%d",&m,&n)&&m!=0&&n!=0) { p++; for(int i=n*(m-1);i<=m*n;i++) b[i]=true; for(i=0;i<n;i++) { scanf("%d",&a[i]); b[a[i]]=false; } qsort(a,n,sizeof(a[0]),cmp); int j,k=0; for(i=0;i<n;i++) { if(a[i]<=n*(m-1)) break; for(j=a[i]+1;j<=m*n;j++) { if(b[j]) { b[j]=false; break; } } if(j==m*n+1) k++; } printf("Case %d: %d\n",p,k); } return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator