d378.
最小路徑
| From: [119.117.177.223] |
發表日期
:
2009-09-10 13:31
var
a:array[1..200,1..200]of longint;
i,j,b,c,n:longint;
function max(b,c:longint):longint;
begin
if b<=c
then max:=b
else max:=c;
end;
begin
n:=0;
while not eof do begin
fillchar(a,sizeof(a),0);
inc(n);
readln(b,c);
for i:=1to b do begin
for j:=1to c do begin
read(a[j,i]);
end;
end;
for i:=1to b do begin
for j:=1to c do begin
if (i<>1)and(j<>1)then begin
a[j,i]:=max(a[j-1,i],a[j,i-1])+a[j,i];
end;
if (i<>1)and(j=1)then begin
a[j,i]:=a[j,i-1]+a[j,i];
end;
if (i=1)and(j<>1)then begin
a[j,i]:=a[j-1,i]+a[j,i];
end;
end;
end;
writeln('Case #',n,' :');
writeln(a[c,b]);
end;
end.
标准DP,但他说多了个CASE #31:和CASE #901:.............= =#