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

计数可能很大 因此 wa 了无限久

Posted by caotong0 at 2011-03-31 12:15:32 on Problem 1002
#include<stdio.h>
#include<string.h>
#define max 10000001
int o[max];
int main()
{
	char s[100];
	int i,j,c;
	int a,n,sum,l;
	scanf("%ld",&n);
	gets(s);
	for(a=0;a<max;a++)
		o[a]=0;
	for(a=0;a<n;a++)
	{
		memset(s,0,sizeof(s));
		gets(s);
		sum=0;
		i=0;
		j=-1;
		l=strlen(s);
		while(j<l)
		{
			j++;
			if(((s[j]>='A')&&(s[j]<'Z'))||((s[j]>='0')&&(s[j]<='9')))
			{
				if((s[j]>='A')&&(s[j]<'Z'))
				{
					if(s[j]<'S')
						c=(s[j]-'A')/3+2;
					else
						c=(s[j]-'A'-1)/3+2;
				}
				else
					c=s[j]-'0';
				i++;
				sum=sum*10+c;
			}
		}
		if(i==7)
			o[sum]++;
	}
	c=0;
	for(a=0;a<max;a++)
		if(o[a]>1)
		{
			c=1;
			i=a/10000;j=a%10000;
			printf("%03d-%04d %d\n",i,j,o[a]);
		}
	if (c==0)
		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