Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
Register

## 呵呵，一下就a了，贴贴代码望大家指点指点

Posted by TSERROF at 2012-09-04 21:11:38 on Problem 1323
```#include <cstdio>
#include <cstring>
bool hash[2800];
int card[1000];
void Count_sort(int *arr,int arr_size)
{

int temp[100001];
memset(temp,0,sizeof(temp));
for (int i=0;i!=arr_size;++i)
{
++temp[arr[i]];
}
int j=0;
for (int i=0;i!=100001;++i)
{
while(temp[i]!=0)
{
arr[j]=i;
--temp[i];
++j;
}
}
}
int main()
{
int  m,n,c=1;
while (scanf("%d%d",&m,&n)!=EOF)
{
if(m==0 && n==0)break;
int ans=0;
memset(hash,true,sizeof(hash));
for(int i=0;i!=n;++i)
{
scanf("%d",&card[i]);
hash[card[i]]=false;
}
Count_sort(card,n);
for(int i=n-1;i>=0;--i)
{
int j=card[i]+1;
bool flag=0;
while(j<=m*n)
{
if(hash[j])
{
flag=1;
hash[j]=false;
break;
}
++j;
}
if(!flag)
{
j=1;
while(!hash[j])++j;
hash[j]=false;
++ans;
}
}
printf("Case %d: %d\n",c++,ans);
}
return 0;
}```

Followed by: