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> int hash[10000000]; int input[7]; int check; int main() { int i,j,k,n; char in; scanf("%d",&n); for(i=0;i<n;i++) { for(j=0;j<7;j++) { scanf("%c",&in); if(in=='-'||in=='\n')j--; else if(in=='A'||in=='B'||in=='C')input[j]=2; else if(in=='D'||in=='E'||in=='F')input[j]=3; else if(in=='G'||in=='H'||in=='I')input[j]=4; else if(in=='J'||in=='K'||in=='L')input[j]=5; else if(in=='M'||in=='N'||in=='O')input[j]=6; else if(in=='P'||in=='R'||in=='S')input[j]=7; else if(in=='T'||in=='U'||in=='V')input[j]=8; else if(in=='W'||in=='X'||in=='Y')input[j]=9; else input[j]=in-'0'; } hash[input[0]*1000000+input[1]*100000+input[2]*10000+input[3]*1000+input[4]*100+input[5]*10+input[6]]++; } for(i=0;i<10000000;i++) { if(hash[i]<=1)continue; check=1; printf("%03d",i/10000); printf("-"); printf("%04d %d\n",i%10000,hash[i]); } if(check==0) printf("No duplicates.\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