NKEDIT - Hiệu chỉnh văn bản
Tác giả: ladpro98
Ngôn ngữ: Pascal
program nkedit;
uses math;
const fi='';
var a,b:string;
k,res:longint;
procedure input;
var f:text;
begin
assign(f,fi);
reset(f);
readln(f,k);
readln(f,a);
readln(f,b);
close(f);
end;
procedure process;
var i,j,startA,startB,maxL,s,t:longint;
begin
res:=0;
repeat
maxL:=0;
for i:=1 to length(a) do
begin
for t:=1 to length(b) do
begin
s:=t;
j:=t;
while (j<=length(b)) and (i+j-t<=length(a)) and (b[j]=a[i+j-t]) do inc(j);
if maxL<(j-s) then
begin
maxL:=j-s;
startA:=i;
startB:=s;
end;
end;
end;
if maxL<k then break;
inc(res);
delete(a,startA,maxL);
delete(b,startB,maxL);
until maxL<k;
end;
begin
input;
process;
writeln(res);
writeln(a);
writeln(b);
end.