|  | 
|  | 
| вернуться в форум | Why Compilation Error??? 2 type vector=array[0..750000] of longint;
 var n:longint;
 s,t:ansistring;
 x:longint;
 
 function qqq(s,t:ansistring):longint;
 var f:vector;
 k,i:longint;
 result:longint;
 begin
 result:=-1;
 f[1]:=0;
 k:=0;
 for i:=2 to length(s) do
 begin
 while (k>0) and (s[k+1]<>s[i]) do k:=f[k];
 if s[k+1]=s[i] then inc(k);
 f[i]:=k;
 end;
 k:=0;
 for i:=1 to length(t) do
 begin
 while (k>0) and (s[k+1]<>t[i]) do k:=f[k];
 if s[k+1]=t[i] then inc(k);
 if k=length(s)
 then
 begin
 result:=i+length(t);
 break;
 end;
 end;
 qqq:=result;
 end;
 
 begin
 readln(n);
 readln(s);
 readln(t);
 x:=qqq(s,t+t);
 writeln(x mod length(s));
 readln;
 end.
 | 
 | 
|