| ||||||||||
| 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 | |||||||||
Re:为什么是WA 样例过了啊In Reply To:为什么是WA 样例过了啊 Posted by:397993401 at 2009-09-15 11:46:18 > # include <stdio.h>
> # include<string.h>
> # include<ctype.h>
> #define MAXN 100004
> #define MAXM 7
> #define MAXHASHVALUE 10000004
> static unsigned int hashTable[MAXHASHVALUE];
> static int mapValue[]=
> {2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,0,7,7,7,8,8,8,9,9,9};
>
> int main()
> {
> int i,j,n,len = 0,sum,num = 0;
>
> char str[MAXN] = {NULL};
> scanf("%d",&n);
> for (i = 0;i < n;i++)
> {
> scanf("%s",str);
> sum = 0;
> for (j = 0,len = strlen(str);j < len ;j++)
> {
> if (isdigit(str[j]))
> sum = sum*10 + str[j] - '0';
> else if (isupper(str[j]))
> sum = sum*10 + mapValue[str[j]-'A'];
> }
> hashTable[sum] ++;
> }
>
> for (int m=0;m<MAXHASHVALUE;m++)
> {
> if (hashTable[m] > 1)
> {
> num ++;
> printf("%d-%d %d\n",m/10000,m%10000,hashTable[m]);
> }
> }
> if(num == 0)
> printf("No duplicates.\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