| ||||||||||
| 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<iostream>
#define max 100001
#define max2 80
int map[]={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 number[max2];
int p[max][7];
int cmp(const void *a, const void *b)
{
return(*(int *)a-*(int *)b);
}
int main()
{
int counter,value=1;
int cellnumber,i,j,k;
scanf("%d",&cellnumber);
for(i=0;i<cellnumber&&scanf("%s",number);i++)
{
for(j=0,k=0;j<max2;j++)
{
if(number[j]>='A'&&number[j]<='Z')
{
p[i][k]=map[number[j]-'A'];
k++;
}
if(number[j]>='0'&&number[j]<='9')
{
p[i][k]=((int)number[j]-48);
k++;
}
}
}
qsort(p,cellnumber,sizeof(p[0]),cmp);
for(i=0;i<cellnumber;i++)
{
if(p[i][0]!=-1)
{
counter=1;
for(j=i+1;j<cellnumber;j++)
{
if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]&&p[i][3]==p[j][3]&&p[i][4]==p[j][4]&&p[i][5]==p[j][5]&&p[i][6]==p[j][6])
{
counter++;
p[j][0]=-1;
}
}
if(counter>1)
{
printf("%d%d%d-%d%d%d%d %d\n",p[i][0],p[i][1],p[i][2],p[i][3],p[i][4],p[i][5],p[i][6],counter );
value=0;
}
}
}
if(value==1)
printf("No duplicates.");
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator