标签:cat i+1 poi size ace i++ ast 元素 first
题目链接:http://poj.org/problem?id=1651
Description
Input
Output
Sample Input
6 10 1 50 50 20 5
Sample Output
3650
#include<iostream> #include<cstdio> #include<algorithm> #include<cstring> using namespace std; #define ll long long const int maxn=1e2+5; const int INF=0x3f3f3f3f; int dp[105][105]; int a[105]; int main() { int n; while(scanf("%d",&n)==1) { memset(dp,0,sizeof(dp)); for(int i=1; i<=n; i++) scanf("%d",&a[i]); for(int d=2; d<n; d++) for(int i=1; i+d<=n; i++){ int j=i+d; dp[i][j]=INF; for(int k=i+1; k<j; k++) dp[i][j]=min(dp[i][j],dp[i][k]+dp[k][j]+a[k]*a[i]*a[j]); } printf("%d\n",dp[1][n]); } return 0; }
标签:cat i+1 poi size ace i++ ast 元素 first
原文地址:http://www.cnblogs.com/a-clown/p/6059913.html