| ||||||||||
| 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 | |||||||||
hash了一下,还是留个脚印吧,*^◎^*#include <cstdio>
#include <cstring>
char customer[100];
int hash[280];
int main()
{
int n;
while (scanf("%d",&n)!=EOF)
{
if(n==0)break;
getchar();
gets(customer);
// puts(customer);
memset(hash,0,sizeof(hash));
int people=0;
int ans=0;
for(int i=0;i!=strlen(customer);++i)
{
if(hash[customer[i]]!=0)
{
--people;
hash[customer[i]]==0;
continue;
}
if(people==n)
{
++ans;
++i;
continue;
}
hash[customer[i]]=1;
++people;
}
if(ans)printf("%d customer(s) walked away.\n",ans);
else printf("All customers tanned successfully.\n");
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator