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:感觉写得还行的代码,贴之: 916K 375MS G++

Posted by Years at 2013-04-08 19:31:55 on Problem 1002
In Reply To:感觉写得还行的代码,贴之: 916K 375MS G++ Posted by:Pcz at 2012-04-22 21:07:24
> #include <cstdio>
> #include <algorithm>
> using namespace std;
> char s[31];
> 
> int Hash()
> {
>     int sum=0;
>     for(int i=0,k=0;k<7;i++)
>     {
>         if(s[i]>='0'&&s[i]<='9')
>         {
>             sum*=10;k++;
>             sum+=(s[i]-'0');
>         }
>         else if(s[i]>='A'&&s[i]<'Z')
>         {
>             sum*=10;k++;
>             sum+=((s[i]-'A'-(s[i]>'Q'))/3+2);
>         }
>     }
>     return sum;
> }
> 
> int main()
> {
> 
>     int n;scanf("%d",&n);
>     int data[n];getchar();
>     for(int tmp=0;tmp<n;tmp++)
>     {
>         gets(s);
>         data[tmp]=Hash();
>     }
>     sort(data,data+n);
>     bool p=false;n--;
>     for(int i=0,num=1;i<n;i+=num=1)
>     {
>         while(data[i]==data[i+1])
>         {
>             num++;
>             i++;
>         }
>         if(num>1)
>         {
>             printf("%03d-%04d %d\n",data[i]/10000,data[i]%10000,num);
>             p=true;
>         }
>     }
>     if(!p)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