讨论 / 简单!Pascal 17
qq913653500 2017-05-08 21:04:35
点我顶贴 收藏 删除
var

a:array[1..100] of integer;

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

f:array[0..101,0..101] of longint;

begin

readln(n);

for i:=1 to n do read(a[i]);

for m:=2 to n do

for i:=1 to n do begin

j:=i+m-1;

for k:=i to j-1 do

if f[i,(j-1) mod n+1]<f[i,(k-1) mod n+1]+f[k mod n+1,(j-1) mod n+1]+a[i]*a[k mod n+1]*a[j mod n+1] then

f[i,(j-1) mod n+1]:=f[i,(k-1) mod n+1]+f[k mod n+1,(j-1) mod n+1]+a[i]*a[k mod n+1]*a[j mod n+1]

end;

for i:=1 to n do if e<f[i,(i+n-2) mod n+1] then e:=f[i,(i+n-2) mod n+1];

writeln(e);

end.

#1 blake312@2017-05-30 20:56:00
回复 删除
好帅!
查看更多回复
提交回复