这个怎么不对啊?

var a:array[1..50,1..50] of integer;

f:array[1..100,1..50,1..50] of int64;

i,j,k,n,m:longint;

function max(a,b,c,d:int64):int64;

begin

max:=a;

if b>max then max:=b;

if c>max then max:=c;

if d>max then max:=d;

end;

begin

readln(m,n);

for i:=1 to m do

for j:=1 to n do

read(a);

f[1,1,1]:=a[1,1];

for i:=2 to m+n-1 do

for j:=2 to n do

for k:=2 to n do

if ((jk) or ((j=n) and (k=n))) and (i+2>j) and (i+2>k) then

f:=max(f+a[j,i+2-j]+a[k,i+2-k],

f+a[j,i+2-j]+a[k,i+2-k],

f+a[j,i+2-j]+a[k,i+2-k],

f+a[j,i+2-j]+a[k,i+2-k]);

writeln(f[m+n-2,n,n]);

end.

1 条评论

  • @ 2009-10-28 17:49:07

    改了一下

    改了一下

    var a:array[1..50,1..50] of integer;

    f:array[0..100,1..50,1..50] of int64;

    i,j,k,n,m:longint;

    function max(a,b,c,d:int64):int64;

    begin

    max:=a;

    if b>max then max:=b;

    if c>max then max:=c;

    if d>max then max:=d;

    end;

    begin

    readln(m,n);

    for i:=1 to m do

    for j:=1 to n do

    read(a);

    f[0,1,1]:=a[1,1];

    for i:=1 to m+n-1 do

    for j:=2 to m do

    for k:=2 to m do

    if ((jk) or ((j=n) and (k=n))) and (i+2>j) and (i+2>k) then

    f:=max(f,f,f,f)+a[j,i+2-j]+a[k,i+2-k];

    writeln(f[m+n-1,m,m]);

    end.

  • 1

信息

ID
1493
难度
5
分类
动态规划 点击显示
标签
递交数
6711
已通过
2508
通过率
37%
被复制
9
上传者