Cod sursa(job #537253)

Utilizator catalin.stStanciu Catalin catalin.st Data 20 februarie 2011 15:01:02
Problema Subsir Scor 0
Compilator fpc Status done
Runda Arhiva de probleme Marime 0.56 kb
var n,s:string;a:array[0..250,0..250]of byte;x,y,max,nr:byte;
procedure citire;begin assign(input,'') readln(n);readln(s);end;
procedure rez;
var i,j,k,l:byte;
begin
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);
end;
begin
citire;
rez;
end.