Pagini recente » Cod sursa (job #2129833) | Cod sursa (job #2654872) | Cod sursa (job #2159014) | Cod sursa (job #688863) | Cod sursa (job #537255)
Cod sursa(job #537255)
var n,s:string;a:array[0..250,0..250]of byte;x,y,max,nr:byte;
procedure citire;begin assign(input,'subsir.in');reset(input); readln(n);readln(s);close(input);end;
procedure rez;
var i,j,k,l:byte;f:text;
begin
assign(f,'subsir.out');rewrite(f);
for i:=1 to length(n) do
for j:=1 to length(s) do if n[i]=s[j] then a[j,i]:=1+a[j-1,i-1];
max:=0;
for i:=1 to length(n) do
for j:=1 to length(s) do if max<a[i,j] then begin max:=a[i,j];a[i,j]:=0;x:=i;y:=j;end;
if max<>0 then nr:=1;
for i:=1 to length(s) do for j:=1 to length(n) do
if (a[i,j]=max) then if (j>=y+max) then begin inc(nr);y:=j;end;
writeln(f,nr);
close(f);
end;
begin
citire;
rez;
end.