#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int next[1000005];
int n;
void Next(char T[])
{
int i=0,j=-1;
next[0]=-1;
while(i<n)
{
if(j==-1||T[j]==T[i])next[++i]=++j;
else j=next[j];
}
}
int main()
{
char T[1000005];
int kase=0;
while(~scanf("%d",&n)&&n!=0)
{
scanf("%s",&T);
Next(T);
printf("Test case #%d\n",++kase);
for(int i=2;i<=n;i++)
{
if(next[i]>0&&i%(i-next[i])==0)printf("%d %d\n",i,i/(i-next[i]));
}
printf("\n");
}
return 0;
}
POJ—1961 Period
最新推荐文章于 2022-07-21 20:47:48 发布