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

Re:AC了,空间换时间,没用排序。“39320K 594MS C 890B”。代码只有30+行。

Posted by scse11_xiaowen at 2012-03-18 17:39:11 on Problem 1002
In Reply To:Re:AC了,空间换时间,没用排序。“39320K 594MS C 890B”。代码只有30+行。 Posted by:szpgod at 2011-04-28 09:36:31
> #include <stdio.h>
> #include <string.h>
> #include <stdlib.h>
> int main()
> {   
>     int phoneNum;
>     int i,j,k,m=0;
>     int tempNum;;
>     int noDupli =0;
>     int len;
>     char str[100]={0};
>     int *flag=NULL;
>     char temp[100]={0};
>     scanf("%d",&phoneNum); 
>     flag=(int*)malloc(10000000*sizeof(int));
>     memset(flag,0,10000000*sizeof(int));
> 
>     for(i =0;i<phoneNum;i++)
>     {   
>         scanf("%s",str);
>         len =strlen(str);
>         k=0;
>         for (j=0;j<len;j++)
>         {
>             if (str[j] == '-' || str[j]=='Q' || str[j]=='Z')
>             {
>                 continue;
>             }
>             if (str[j]>='A' && str[j]<='C')
>             {
>                 temp[k++]='2';
>             }
>           else  if (str[j]>='D' && str[j]<='F')
>             {
>                 temp[k++]='3';
>             }
>           else if (str[j]>='G' && str[j]<='I')
>             {
>                 temp[k++]='4';
>             }
>           else  if (str[j]>='J' && str[j]<='L')
>             {
>                 temp[k++]='5';
>             }
>           else  if (str[j]>='M' && str[j]<='O')
>             {
>                 temp[k++]='6';
>             }
>           else  if (str[j]>='P' && str[j]<='S')
>             {
>                 temp[k++]='7';
>             }
>           else  if (str[j]>='T' && str[j]<='V')
>             {
>                 temp[k++]='8';
>             }
>           else  if (str[j]>='W' && str[j]<='Y')
>             {
>                 temp[k++]='9';
>             }
>           else  if (str[j]>='0' && str[j]<='9')
>             {
>                 temp[k++] =str[j];
>             }
>          
>         }
>         temp[k++]='\0';
>         tempNum =atoi(temp);
>         flag[tempNum]++;
>         memset(temp,0,k);
>     }
>     for (i=0;i<10000000;i++)
>     {
>         if (flag[i]>1)
>         {   
>             noDupli =1;
>             printf("%03d-%04d %d\n",i/10000,i%10000,flag[i]);
>         }
>     }
>     if (!noDupli)
>     {
>         printf("No duplicates.");
>     }
>     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