竟然while(scanf("%d",&n)&&n)会TLE而while(scanf("%d",&n)!=EOF&&n)就0msAC……铭记……
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=1004

#include < iostream >
using   namespace  std;
char  dic[ 1001 ][ 16 ];
int  maxcnt,best;
struct  Trie
{
    
int  next[ 26 ];
    
int  cnt;
    
void  init(){memset(next, - 1 , sizeof (next));}
};
int  p;
Trie T[
1000000 ];
int  build() // 建树 
{
    p
= 1 ;
    T[p].init();
    T[p].cnt
= 0 ;
    maxcnt
= 0 ;
    best
= 0 ;
}
int  insert( char  c[], int  m) // 插入单词并统计 
{
    
int  indx = 1 ;
    
int  i;
    
for (i = 0 ;i < strlen(c);i ++ )
    {
        
if (T[indx].next[c[i] - ' a ' ] ==- 1 )
        {
            T[indx].next[c[i]
- ' a ' ] =++ p;
            T[T[indx].next[c[i]
- ' a ' ]].init();
            T[T[indx].next[c[i]
- ' a ' ]].cnt = 0 ;
        }
        indx
= T[indx].next[c[i] - ' a ' ];
    }
    T[indx].cnt
++ ;
    
if (T[indx].cnt > maxcnt)
    {
        maxcnt
= T[indx].cnt;
        best
= m;
    }
    
return   0 ;
}
int  main()
{
    
int  n;
    
int  i,j;
    
while (scanf( " %d " , & n)!=EOF)
    {
        
        
if (n == 0 )
            
return   0 ;
        build();
        
for (i = 1 ;i <= n;i ++ )
        {
            scanf(
" %s " ,dic[i]);
            insert(dic[i],i);
        }
        printf(
" %s\n " ,dic[best]);
    }
    
// system("pause");
     return   0 ;
}