//和poj2406同样处理 //一个失败函数就行 //因为s=a^n,所以如果i%(i-f[i])==0,那么其a的长度就是i-f[i]了 #include <iostream> #include<stdio.h> #include<string.h> #include<algorithm> using namespace std; #define N 1000005 int n,m,t,p,end; char str[N]; int f[N]; int main() { end++; while(scanf("%d",&n),n) { scanf("%s",str); int i,j,k; f[0]=j=-1,i=0; while(i<n) { if(j==-1||str[i]==str[j]) { ++i,++j; f[i]=j; } else j=f[j]; } printf("Test case #%d\n",end++); for(i=2;i<=n;i++) { if(i%(i-f[i])==0&&i/(i-f[i])!=1) { printf("%d %d\n",i,i/(i-f[i])); } } puts(""); } return 0; }