Pagini recente » Cod sursa (job #2555972) | Cod sursa (job #2592395) | Cod sursa (job #1163683) | Cod sursa (job #2109299) | Cod sursa (job #48217)
Cod sursa(job #48217)
var a,b:array[1..1000000]of char;
t,i,j,max,n,s,z,l,q,te:longint;
begin
assign(input,'prefix.in');
reset(input);
assign(output,'prefix.out');
rewrite(output);
readln(t);
for te:=1 to t do
begin
n:=0;
while not eoln do
begin
n:=n+1;
read(a[n]);
end;
readln;
max:=0;
for i:=1 to n div 2 do
begin
b[i]:=a[i];
s:=i;
q:=1;
l:=i;
while (q=1)and(l+i<=n) do
begin
for j:=l+1 to l+i do
begin
if a[j]<>b[j-l] then
begin
q:=0;
break;
end;
end;
l:=l+i;
if q=1 then s:=s+i;
end;
if (s>i)and(max<s) then max:=s;
end;
writeln(max);
end;
close(output);
end.