标签:style blog io color os sp for on div
1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 using namespace std; 5 int m,n,lose,x; 6 bool flag[1010],v[1010]; 7 bool cmp(int a,int b) 8 { 9 return a>b; 10 } 11 int main() 12 { 13 scanf("%d%d",&m,&n); 14 int t=0; 15 while (m!=0) 16 { 17 t++; 18 memset(v,0,sizeof(v)); 19 memset(flag,0,sizeof(flag)); 20 for (int i=1;i<=n;i++) 21 { 22 scanf("%d",&x); 23 flag[x]=1; 24 } 25 lose=0; 26 for (int i=m*n;i>1;i--) 27 if (flag[i]==0) 28 for (int j=i-1;j>=1;j--) 29 if (flag[j]==1 && v[j]==0) 30 { 31 lose++; 32 v[j]=1; 33 break; 34 } 35 printf("Case %d: %d\n",t,n-lose); 36 scanf("%d%d",&m,&n); 37 } 38 return 0; 39 }
标签:style blog io color os sp for on div
原文地址:http://www.cnblogs.com/NicoleLam/p/4158659.html