- 摆花
- 2014-11-05 18:46:56 @
var
n:longint;
f:array[1..100,1..100]of longint;
a,s:array[0..100]of longint;
i,j,k:longint;
function min(i,j:longint):longint;
begin
if i<j then min:=i
else min:=j;
end;
begin
readln(n);
for i:=1 to n do
read(a[i]);
for i:=1 to n do
s[i]:=s[i-1]+a[i];
fillchar(f,sizeof(f),$7f div 3);
for i:=1 to n do
f[i,i]:=0;
for i:=n downto 1 do
for j:=i+1 to n do
for k:=i to j-1 do
f[i,j]:=min(f[i,j],f[i,k]+f[k+1,j]+s[j]-s[i-1]);
writeln(f[1,n]);
end.
1 条评论
-
doc LV 10 MOD @ 2014-11-05 19:37:59
你想说啥?
- 1