#include #include #include #include using namespace std; #define N 100005 int ws1[N],wv[N],wa[N],wb[N]; int ran[N],height[N],sa[N],len; char str[N],xiao; int dp[N][25]; int min(int x,int y) { return x=0;i--) sa[--ws1[x[i]]]=i; for(j=1,p=1;p=j) y[p++]=sa[i]-j; for(i=0;i=0;i--) sa[--ws1[wv[i]]]=y[i]; for(t=x,x=y,y=t,p=1,x[sa[0]]=0,i=1;iy) swap(x,y); x++; t=(int)(log(double(y-x+1))/log(2.00)); return min(dp[x][t],dp[y-(1<=0&&k+i>j&&str[k]==str[k+i];k--) { cnt++; if(cnt==t) { num++; p=k; } else if(ran[k]ran[p]) { f=p; node=i; } } } if(max==1) { printf("%c\n",xiao); return ; } for(i=f;i<=f+max*node-1;i++) printf("%c",str[i]); printf("\n"); } int main() { int T=0,i; while(scanf("%s",str)!=EOF&&str[0]!='#') { T++; len=strlen(str); xiao='z'+1; for(i=0;i