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

10000000

Posted by getgoingcc at 2012-10-05 16:08:54 on Problem 1002 and last updated at 2012-10-05 16:09:10
# include <stdio.h>
# include <ctype.h>
# include <string.h>

# define N 10000000

int n, f[N];
int m(char ch)
{
	if (ch < 'Q') return (ch-'A')/3 + 2;
	switch(ch)
	{
		case 'R':case 'S':return 7;
		case 'T':case 'U':case 'V':return 8;
		case 'W':case 'X':case 'Y':return 9;
	}
}
int g(char *s)
{
	int i, ret = 0;
	for (i = 0; s[i]; ++i)
	{
		if (isdigit(s[i])) ret = ret*10 + s[i]-'0';
		else if (isalpha(s[i])) ret = ret*10 + m(s[i]);
	}
	return ret;
}
int main()
{
	int i, dup;
	char buf[105];
	while (~scanf("%d", &n))
	{
		memset(f, 0, sizeof(f));
		for (i = 0; i < n; ++i)
		{
			scanf("%s", buf);
			++f[g(buf)];
		}
		dup = 1;
		for (i = 0; i < 10000000; ++i)
			if (f[i] > 1) printf("%03d-%04d %d\n", i/10000, i%10000, f[i]), dup = 0;
		if (dup) printf("No duplicates. \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