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

memory limit 郁闷了,来帮我改一下吧

Posted by fxlbest at 2005-11-03 17:38:26 on Problem 1002
#include <stdio.h>
#include <stdlib.h>
int a[10000000]={0};
int que[50001];
int cmp(const void *a,const void *b) {
    return *(int *)a-*(int *)b;
}
int main() {
    int b[26]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,7,8,8,8,9,9,9,9};
    char s[100];
    int n,i;
    int k;
    int r;
    int num;
    int temp;
    scanf("%d",&n);
    r=0;
    for(i=0;i<n;i++) {
        num=0;
        scanf("%s",s);
        for(k=0;s[k]!='\0';k++) {
            if(s[k]>='A' && s[k]<='Z'){ num=10*num+b[s[k]-'A'];continue;}
            if(s[k]>='0' && s[k]<='9') num=10*num+s[k]-'0';
        }
        ++a[num];
        if(a[num]==2) {
            que[r]=num;
            ++r;
        }

    }
    if(r==0){
        printf("No duplicates.\n");
    }    
    else {   
    qsort(que,r,sizeof(que[0]),cmp);
    for(i=0;i<r;i++) {
        temp=que[i]; 
        printf("%.3d-%.4d %d\n",temp/10000,temp%10000,a[que[i]]);  
    }
}    

    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