题目: |
Program cx2016p3;
var x:string;
i, j,n: integer;
a:array[0..20, 0..20] of integer;
begin
readln(x);
n:=length(x);
for i:=1 to n do
for j:=1 to n do
if x[i]=x[n-j+1] then a[i,j] :=a[i-1, j-1]+1
else if a[i-1, j]>a[i, j-1] then a[i, j] :=a[i-1,j]
else a[i, j] :=a[i, j-1];
writeln(a[n, n]);
end.
输入:acbfaebkbga 输出:5
|