不是VIP会员,不能显示答案

题目解答

题目:
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
考点: 0
分析: 回文序列
解答: 最长回文子序列
评论:
老师: 0