| ||||||||||
| 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?#include <iostream>
#include <cstring>
using namespace std;
struct vec{
int data;
struct vec *next[10];
};
struct vec *head,*q;
void insert(int a){
int i;
struct vec *p;
if(q->next[a]){
q=q->next[a];
q->data++;
}else{
p=new vec;
for(i=0;i<10;++i){
p->next[i]=NULL;
}
p->data=1;
q->next[a]=p;
q=q->next[a];
}
}
int locate(char a){
switch(a)
{
case 'A': return 2;
case 'B': return 2;
case 'C': return 2;
case 'D': return 3;
case 'E': return 3;
case 'F': return 3;
case 'G': return 4;
case 'H': return 4;
case 'I': return 4;
case 'J': return 5;
case 'K': return 5;
case 'L': return 5;
case 'M': return 6;
case 'N': return 6;
case 'O': return 6;
case 'P': return 7;
case 'S': return 7;
case 'R': return 7;
case 'T': return 8;
case 'V': return 8;
case 'U': return 8;
case 'W': return 9;
case 'X': return 9;
case 'Y': return 9;
default:
return a-48;
}
}
main(){
#ifndef ONLINE_JUDGE
freopen("test.txt","r",stdin);
#endif
int ch;
int n,i,j=0;
int i1,i2,i3,i4,i5,i6,i7;
struct vec *t1,*t2,*t3,*t4,*t5,*t6;
cin>>n;
head=new vec;
head->data=0;
for(i=0;i<10;++i){
head->next[i]=NULL;
}
getchar();
for(i=1;i<=n;){
q=head;
while(1){
ch=getchar();
if(ch=='\n'||ch==EOF){
++i;
break;
}
if(ch!='-'){
insert(locate(ch));
}
}
}
q=head;
for(i1=0;i1<10;++i1){
if(head->next[i1]){
for(i2=0;i2<10;++i2){
if(head->next[i1]->next[i2]){
for(i3=0;i3<10;++i3){
if(head->next[i1]->next[i2]->next[i3]){
for(i4=0;i4<10;++i4){
if(head->next[i1]->next[i2]->next[i3]->next[i4]){
for(i5=0;i5<10;++i5){
if(head->next[i1]->next[i2]->next[i3]->next[i4]->next[i5]){
for(i6=0;i6<10;++i6){
if(head->next[i1]->next[i2]->next[i3]->next[i4]->next[i5]->next[i6]){
for(i7=0;i7<10;++i7){
if(head->next[i1]->next[i2]->next[i3]->next[i4]->next[i5]->next[i6]->next[i7]){
if(head->next[i1]->next[i2]->next[i3]->next[i4]->next[i5]->next[i6]->next[i7]->data>1){
cout<<i1<<i2<<i3<<'-'<<i4<<i5<<i6<<i7<<' '<<head->next[i1]->next[i2]->next[i3]->next[i4]->next[i5]->next[i6]->next[i7]->data<<endl;
}
}
}
}
}
}
}
}
}
}
}
}
}
}
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator