http://acm.hdu.edu.cn/showproblem.php?pid=1800

/**//*
5
1001
0010
0110
2
4
*/
#include<iostream>
using namespace std;
int i;
struct dictree


{
struct dictree *child[10];
int num;
dictree()

{
for(i=0;i<10;i++)
child[i]=NULL;
num = 0;
}
~dictree()

{
for(i=0;i<10;i++)
if(child[i])
delete child[i];
}
};
int main()


{
int n;
while(cin>>n)

{
int maxs = 0;
char digit[31];
struct dictree root;
while(n--)

{
cin>>digit;
char *tmp = digit;
while(*tmp == '0')//去掉前綴0
tmp++;
struct dictree *now = &root;
while(*tmp>='0' && *tmp<='9')//注意不能寫成*tmp

{
if(now->child[*tmp-'0'] == NULL)
now->child[*tmp-'0'] = new dictree;
now = now->child[*tmp-'0'];
//now->num++;//不能再加
tmp++;
}
now->num++;
if( maxs < now->num)
maxs = now->num;
}
cout<<maxs<<endl;
}
return 0;
}









































































