poj2406 周期

时间:2022-07-08 18:46:01

脑残wa了一次

 var  s:ansistring;
ans,i,k,m:longint;
pre:array[..] of longint;
function max(x,y:longint):longint;
begin
if x>y then exit(x) else exit(y);
end;
procedure main;
begin
pre[]:=;k:=;
for i:= to length(s) do
begin
while (k<>) and (s[k+]<>s[i]) do k:=pre[k];
if s[k+]=s[i] then inc(k);
pre[i]:=k;
end;
m:=length(s);
if m mod (m-pre[m])= then writeln(m div (m-pre[m])) else writeln('');
end;
begin
while true do
begin
readln(s);if s='.' then break;
main;
end;
end.