| ||||||||||
| 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 | |||||||||
现在变wa了In Reply To:Re:哭求请教,实在是郁闷,总是超时 Posted by:evernever at 2006-03-18 18:21:41 #include<stdio.h>
#include <stdlib.h>
int n,i,j,k,l=0;
char a[100001][100];
int num[]={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};
int count[10000];
long tele[100001];
int compare(const void *a,const void *b){
return (*(int *)a-*(int *)b);
}
void main(){
scanf("%d",&n);
for(i=0;i<n;i++){
tele[i]=0;
k=0;
scanf("%s",&a[i]);
for(j=0;a[i][j]!='\0';j++){
if(a[i][j]>='A' && a[i][j]<='Y'){
tele[i]=tele[i]+num[a[i][j]-'A'];
tele[i]=tele[i]*10;
}
else if(a[i][j]>='0' && a[i][j]<='9'){
tele[i]=tele[i]+a[i][j]-'0';
tele[i]=tele[i]*10;
}
}
tele[i]=tele[i]/10;
}
qsort((void *)tele,n,sizeof(int),compare);
for(i=0;i<n;i++){
if(tele[i]==tele[i+1]){
tele[i]=0;
if(tele[i-1]==0)
count[i+1]=count[i]+count[i+1]+1;
else count[i+1]=count[i]+count[i+1]+2;
}
if(count[i]>1 && tele[i]!=0){
l=1;
printf("%03d-%04d %d\n",tele[i]/10000,tele[i]%10000,count[i]);
}
}
if(l!=1) printf("No duplicates.\n");
}
Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator