传送门
http://oi.nks.edu.cn/showproblem?problem_id=2201
http://poj.org/problem?id=1961
题解
const
maxn=1000005;
var
next:array[0..maxn]of longint;
i,j,k:longint;
n,m:longint;
a:ansistring;
begin
m:=0;
while not eof do
begin
readln(n); if n=0 then break;
readln(a); inc(m);
next[1]:=0; j:=0;
for i:=2 to n do
begin
while (j>0)and(a[j+1]<>a[i]) do j:=next[j];
if a[j+1]=a[i] then inc(j);
next[i]:=j;
end;
writeln('Test case #',m);
for i:=2 to n do
if (i mod (i-next[i])=0)and(i div (i-next[i])>1)
then writeln(i,' ',i div (i-next[i]));
writeln;
end;
end.