标签:cst int space sizeof 代码 multi ems out pac
#include <iostream>
#include <cstring>
using namespace std;
int dp[666][666],num[666];
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
memset(dp,0x7f,sizeof(dp));
for(int i=1;i<=n;i++)
cin>>num[i],dp[i][i]=0;
for(int i=2;i<n;i++)
for(int j=1;j<=n;j++)
{
int end=i+j-1;
if(end>n)
continue;
for(int k=j;k<end;k++)
dp[j][end]=min(dp[j][end],dp[j][k]+dp[k+1][end]+num[k]*num[j-1]*num[end]);
}
cout<<dp[2][n];
}
Multiplication Puzzle POJ - 1651
标签:cst int space sizeof 代码 multi ems out pac
原文地址:https://www.cnblogs.com/baccano-acmer/p/10326146.html