#include<iostream>
#include<stdio.h>
#define MAXN 1000001
using namespace std; char c[MAXN];
int next[MAXN]; void give_next(int len)
{
int i;
int j;
i=,j=-;
next[]=-;
while(i < len)
{
if(j == - || c[i] == c[j])
{
i ++;
j ++;
next[i] = j;
}
else
j = next[j];
}
} int main()
{
//freopen("acm.acm","r",stdin);
int size;
int tem;
int tem1;
int time = ;
while(scanf("%d",&size) != EOF,size)
{
cout<<"Test case #"<<++ time<<endl;
scanf("%s",c);
int i;
give_next(size);
for(i = ; i <= size; ++ i)
{
if(next[i-] != -)
{
tem = i - (next[i]);
if(i % tem == )
{
tem1 = i/tem;
if(tem1 > )
cout<<i<<" "<<tem1<<endl;
}
}
}
cout<<endl;
}
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。
技术网站地址: vmfor.com