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 |
WHY?WHY?WHY?这样可以过: #include<stdio.h> #include<iostream.h> int main() { int m,n,number=0; while(scanf("%d%d",&m,&n)==2) {if(m==0&&n==0) break;number++; int i,i1,a[1001],t[50],num=0; for(i=1;i<=m*n;i++) a[i]=1; for(i=0;i<n;i++) {scanf("%d",&t[i]);a[t[i]]=0;} for(i=0;i<n;i++) {if(t[i]==m*n) num++; else { for(i1=t[i]+1;i1<=m*n;i1++) if(a[i1]==1) {a[i1]=0;break;} if(i1==m*n+1) num++; } } printf("Case %d: %d\n",number,num); } return 0; } 这样就不可以过了: #include<stdio.h> #include<iostream.h> int main() { int m,n,number=0; while(scanf("%d%d",&m,&n)==2) {if(m==0&&n==0) break;number++; int i,i1,a[1001],t[50],num=0; for(i=1;i<=m*n;i++) a[i]=1; for(i=0;i<n;i++) {cin>>t[i];a[t[i]]=0;} for(i=0;i<n;i++) {if(t[i]==m*n) num++; else { for(i1=t[i]+1;i1<=m*n;i1++) if(a[i1]==1) {a[i1]=0;break;} if(i1==m*n+1) num++; } } printf("Case %d: %d\n",number,num); } return 0; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator