标签:阶段 pac str 动态规划 clu divide i+1 for ide
#include <iostream> #include <cstdio> using namespace std; int dp[105][105],dpb[105][105]; int main(){ int n;cin>>n; for(int i=1;i<=n;i++){ cin>>dp[i][i]; } //length begin mid for(int i=2;i<=n;i++){ for(int j=1;j<=n-i+1;j++){ int end=i+j-1; dpb[j][end]=0x7f; for(int k=j;k<end;k++){//divide //begin-k k+1-end dp[j][end]=dp[j][k]+dp[k+1][end]; dpb[j][end]=min(dpb[j][end],dp[j][end]+dpb[j][k]+dpb[k+1][end]); } } } cout<<dpb[1][n]; return 0; }
标签:阶段 pac str 动态规划 clu divide i+1 for ide
原文地址:https://www.cnblogs.com/mooling/p/13616192.html