QBSTR - Xâu con chung dài nhất
Tác giả: ladpro98
Ngôn ngữ: Pascal
{$H+}
program dayconchungdainhat1;
uses math;
var s1,s2:string;
i,j:word;
f:array[0..1000,0..1000] of longint;
begin
readln(s1);
readln(s2);
for i:=1 to length(s1) do f[i,0]:=0;
for i:=1 to length(s2) do f[0,i]:=0;
for i:=1 to length(s1) do
for j:=1 to length(s2) do
begin
if s1[i]=s2[j] then f[i,j]:=f[i-1,j-1]+1
else f[i,j]:=max(f[i,j-1],f[i-1,j]);
end;
write(f[i,j]);
end.