显示代码纯文本
#include<cstdio>
#include<cstring>
#define syy myson
#define INF 0x7fffffff
using namespace std;
int n,a[210],f[210][210],maxx=0,i,j,k;
inline int max(int a,int b)
{return a>b?a:b;}
int Main()
{
freopen("energy.in","r",stdin); freopen("energy.out","w",stdout);
memset(f,0,sizeof(f));
scanf("%d",&n);
for(i=1;i<=n;i++)
{
scanf("%d",&a[i]);
a[i+n]=a[i];
}
for(i=2;i<=n+1;i++)for(j=1;j+i-1<=(n<<1);j++)for(k=j+1;k<=j+i-2;k++)
f[j][j+i-1]=max(f[j][j+i-1],f[j][k]+f[k][j+i-1]+a[j]*a[k]*a[j+i-1]);
for(i=1;i<=n;i++)maxx=max(maxx,f[i][i+n]);
printf("%d\n",maxx);
return 0;
}
int main(){;}
int syy=Main();