标签:style blog http color java os io for
6 10 1 50 50 20 5
3650
1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorithm> 6 #include <climits> 7 #include <vector> 8 #include <queue> 9 #include <cstdlib> 10 #include <string> 11 #include <set> 12 #include <stack> 13 #define LL long long 14 #define INF 0x3f3f3f3f 15 using namespace std; 16 int dp[110][110],d[110],n; 17 int main(){ 18 int i,j,k; 19 while(~scanf("%d",&n)){ 20 for(i = 1; i <= n; i++) 21 scanf("%d",d+i); 22 memset(dp,0,sizeof(dp)); 23 for(k = 3; k <= n; k++){ 24 for(i = 1; i+k-1 <= n; i++){ 25 dp[i][i+k-1] = INF; 26 for(j = i+1; j < i+k; j++) 27 dp[i][i+k-1] = min(dp[i][i+k-1],dp[i][j]+dp[j][i+k-1]+d[i]*d[j]*d[i+k-1]); 28 } 29 } 30 cout<<dp[1][n]<<endl; 31 } 32 return 0; 33 }
xtu read problem training 4 B - Multiplication Puzzle,布布扣,bubuko.com
xtu read problem training 4 B - Multiplication Puzzle
标签:style blog http color java os io for
原文地址:http://www.cnblogs.com/crackpotisback/p/3900612.html