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> int flag[1001]; int main() { int m,n,i,j,temp,count,l=0; for(i=0;i<1001;i++) { flag[i]=0; } while(1) { l++; scanf("%d%d",&m,&n); if(m==0&&n==0) break; for(i=0;i<n;i++) { scanf("%d",&temp); flag[temp]=1; } count=0; for(i=m*n;i>0;i--) { if(flag[i]==1) { count++; } else if(flag[i]==0) { for(j=i-1;j>0;j--) { if(flag[j]==1) { flag[j]=2; break; } } if(j<=0) break; } } printf("Case %d: %d\n",l,count); } return 0; } 同样的算法 count 从n减就对了。。。 Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator