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

hash了一下,还是留个脚印吧,*^◎^*

Posted by TSERROF at 2012-09-04 20:34:35 on Problem 1250
#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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator