方程: dp[i][j] = min(dp[i][k] + dp[k][j] + a[i] * a[k] * a[j] , dp[i][j] )
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string.h>
#include <algorithm>
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 100+5;
int a[maxn];
int dp[maxn][maxn];
int n ;
int main()
{
cin >> n;
for(int i = 0 ; i < n ; i++)
{
scanf("%d",&a[i]);
}
for(int len = 2 ; len <= n ; len++)
{
for(int i = 0 ; i + len <= n-1 ; i++)
{
int j = i + len;
dp[i][j] = INF;
for(int k = i+1 ; k < j ; k++)
{
dp[i][j] = min(dp[i][k] + dp[k][j] + a[k] * a[i] * a[j] , dp[i][j]);
}
}
}
cout << dp[0][n-1] << endl;
return 0;
}