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

no idea

Posted by 526496390 at 2008-04-28 14:57:33 on Problem 1002
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
int comp(const void* a,const void *b) 
{ 
    int *x=(int*)a; 
    int *y=(int*)b; 
    return *x-*y;  
}      
using namespace std;
int main()
{
     int n;
     scanf("%d",&n);
     int num[100001];
     int i;
     for(i=0;i<n;i++)
     {
       char a[1000];
       cin>>a;
       num[i]=0;
       int t=0;
       for(;t<strlen(a);t++)
       {
           if(a[t]>='0'&&a[t]<='9')
             num[i]=num[i]*10+a[t]-'0';
           switch(a[t]-'A')
           {
               case 0:
               case 1:
               case 2:   num[i]=num[i]*10+2;
                         break;
               case 3:
               case 4:
               case 5:   num[i]=num[i]*10+3;
                         break;
               case 6:
               case 7:
               case 8:   num[i]=num[i]*10+4;
                         break;
               case 9:
               case 10:
               case 11:  num[i]=num[i]*10+5;
                         break;
               case 12:
               case 13:
               case 14:  num[i]=num[i]*10+6;
                         break;
               case 15:
               case 17:
               case 18:   num[i]=num[i]*10+7;
                          break;
               case 19:
               case 20:
               case 21:   num[i]=num[i]*10+8;
                          break;
               case 22:
               case 23:
               case 24:   num[i]=num[i]*10+9;
                          break;
               default:
                       break;
             }
       }
    }
    qsort(num,n,sizeof(int),comp);
    int temp=num[0];
    int times=1;
    bool flag=true;
    for(i=1;i<n;i++)
    {
       if(num[i]==temp)
          times++;
       else
       {
          if(times>1)
          {
              flag=false;
              printf("%03d-%04d %d\n",temp/10000,temp%10000,times);
          }
          times=1;
          temp=num[i];
       }
    }
    if(flag)
       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