OI帝国 2010-02-11 01:20:00
点我顶贴
收藏
删除
var a:array[0..2000,0..2000]of longint;
sa,sb:ansistring;
n,m,i,j,t,k:longint;
begin
readln(sa);
n:=length(sa);
readln(sb);
m:=length(sb);
readln(k);
for i:=1 to n do a[i,0]:=i*k;
for j:=1 to m do a[0,j]:=j*k;
a[0,0]:=0;
for i:=1 to n do
for j:=1 to m do
begin
t:=a[i,j-1]+k;
if a[i-1,j]+k<t then t:=a[i-1,j]+k;
if a[i-1,j-1]+abs(ord(sa[i])-ord(sb[j]))<t then t:=a[i-1,j-1]+abs(ord(sa[i])-ord(sb[j]));
a[i,j]:=t;
end;
writeln(a[n,m]);
end.
这程序为啥只有40分???