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 |
大牛们给俺看看哪地方导致超时了!!!!!#include<stdio.h> #include<memory> #include<math.h> #include<stdlib.h> int cmp(const void *a,const void *b) { return *(int *)a-*(int *)b; } int main() { int n,i,j,k,p,c,b,K; char d[25]="ABCDEFGHIJKLMNOPRSTUVWXY"; int D[25]={2,2,2,3,3,3,4,4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,9}; while(scanf("%d",&n)!=EOF) { char a[n+1][20]; int A[n+1],B[n+1][2]; memset(B,0,sizeof(B)); memset(A,0,sizeof(A)); for(i=0;i<n;i++) { scanf("%s",a[i]); b=strlen(a[i]); c=0; for(j=b-1;j>=0;j--) { if(a[i][j]>='0'&&a[i][j]<='9') A[i]=A[i]+((a[i][j]-'0')*(int)pow(10.0,c)),c++; else if(a[i][j]>='A'&&a[i][j]<='C') A[i]=A[i]+(2*(int)pow(10.0,c)),c++; else if(a[i][j]>='D'&&a[i][j]<='F') A[i]=A[i]+(3*(int)pow(10.0,c)),c++; else if(a[i][j]>='G'&&a[i][j]<='I') A[i]=A[i]+(4*(int)pow(10.0,c)),c++; else if(a[i][j]>='J'&&a[i][j]<='L') A[i]=A[i]+(5*(int)pow(10.0,c)),c++; else if(a[i][j]>='M'&&a[i][j]<='O') A[i]=A[i]+(6*(int)pow(10.0,c)),c++; else if(a[i][j]>='P'&&a[i][j]<='S') A[i]=A[i]+(7*(int)pow(10.0,c)),c++; else if(a[i][j]>='T'&&a[i][j]<='V') A[i]=A[i]+(8*(int)pow(10.0,c)),c++; else if(a[i][j]>='W'&&a[i][j]<='Y') A[i]=A[i]+(9*(int)pow(10.0,c)),c++; } } c=0,k=0,K=0; for(i=0;i<n-1;i++) { if(A[i]!=12345678) { b=1; for(j=i+1;j<n;j++) if(A[i]==A[j]) b++,A[j]=12345678; if(b>1) B[c][0]=A[i],B[c][1]=b,c++; } } if(c==0) {printf("No duplicates.\n");} else { qsort(B,c,sizeof(B[0]),cmp); for(i=0;i<c;i++) { for(j=6;j>=0;j--) { if(j==3) {printf("-%d",B[i][0]/((int)pow(10.0,j))); B[i][0]=B[i][0]%((int)pow(10.0,j));} else {printf("%d",B[i][0]/((int)pow(10.0,j))); B[i][0]=B[i][0]%((int)pow(10.0,j));} } printf(" %d",B[i][1]); printf("\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