#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <string>
#include <map>
#include <cmath>
#include <vector> #define Faster ios::sync_with_stdio(false),cin.tie(0)
#define Read freopen("in.txt","r",stdin),freopen("out.txt","w",stdout)
#define Close fclose(stdin),fclose(stdout)
const int maxn = ;
using namespace std;
const int MOD = 1e9+;
typedef long long ll; #define INF 100000000 int a[maxn];
int dp[maxn][maxn]; int main(){
Faster;
int n;
cin >> n;
for(int i = ;i <= n;i++){
cin >> a[i];
}
memset(dp, , sizeof(dp));
for(int l = ;l < n;l++){ //长度从2开始
for(int i = ;i+l <= n+;i++){
int j = i+l-;
dp[i][j] = INF;
for(int k = i;k < j;k++){ //枚举中点
dp[i][j] = min(dp[i][j], dp[i][k]+dp[k+][j] + a[i-]*a[k]*a[j]);
}
}
}
cout << dp[][n] << endl;
return ;
}

E - Multiplication Puzzle的更多相关文章

  1. poj 1651 Multiplication Puzzle (区间dp)

    题目链接:http://poj.org/problem?id=1651 Description The multiplication puzzle is played with a row of ca ...

  2. POJ1651:Multiplication Puzzle(区间DP)

    Description The multiplication puzzle is played with a row of cards, each containing a single positi ...

  3. ZOJ 1602 Multiplication Puzzle(区间DP)题解

    题意:n个数字的串,每取出一个数字的代价为该数字和左右的乘积(1.n不能取),问最小代价 思路:dp[i][j]表示把i~j取到只剩 i.j 的最小代价. 代码: #include<set> ...

  4. POJ 1651 Multiplication Puzzle (区间DP)

    Description The multiplication puzzle is played with a row of cards, each containing a single positi ...

  5. Poj 1651 Multiplication Puzzle(区间dp)

    Multiplication Puzzle Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 10010   Accepted: ...

  6. POJ 1651 Multiplication Puzzle(类似矩阵连乘 区间dp)

    传送门:http://poj.org/problem?id=1651 Multiplication Puzzle Time Limit: 1000MS   Memory Limit: 65536K T ...

  7. Multiplication Puzzle ZOJ - 1602

    Multiplication Puzzle ZOJ - 1602 传送门 The multiplication puzzle is played with a row of cards, each c ...

  8. POJ1651 Multiplication Puzzle —— DP 最优矩阵链乘 区间DP

    题目链接:https://vjudge.net/problem/POJ-1651 Multiplication Puzzle Time Limit: 1000MS   Memory Limit: 65 ...

  9. xtu read problem training 4 B - Multiplication Puzzle

    Multiplication Puzzle Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. O ...

  10. 题解【POJ1651】Multiplication Puzzle

    Description The multiplication puzzle is played with a row of cards, each containing a single positi ...

随机推荐

  1. MFC获取电脑硬盘序列号(附源代码)

    在新建的project里面加入一个类  即:下面一个类  GetHDSerial.cpp <code class="hljs cs has-numbering" style= ...

  2. 20170316 ABAP注意点

    1.debug 时在MODIFY db from table 后数据便提交了: 一般情况下,更新数据库需要commit,但debug会自动commit,程序结束也会自动commit. 2.使用at n ...

  3. Hibernate总结(转)

    原文:http://blog.csdn.net/yuebinghaoyuan/article/details/7300599 那我们看一下hibernate中整体的内容: 我们一一介绍其中的内容. H ...

  4. PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib64/php/modules/redis.so' - /usr/lib64/php/modules/redis.so: undefined symbol: igbinary_serialize in Unknown on line 0

    网上找到两种解决方法, 1.先删除php-pecl-redis,再用pecl install redis 2.安装php-igbinary模块,不过我安装时包冲突了,没有安装成功,所以用了第一种方法

  5. Android Studio 卡顿解决

    每次升级/安装 Android Studio 之后最好都修改一下这个参数:到 Android Studio 安装目录,找到 bin/studio(64?).vmoptions(文件名可能因操作系统而不 ...

  6. ffmpeg 编码h264 profile如何设置为baseline的问题

    http://blog.csdn.net/kisaa133/article/details/7792008 使用最新版ffmpeg-0.11 libx264-125,使用默认编码时,用Eyecard发 ...

  7. ES6 对Number的扩展

    Number.isFinite(), Number.isNaN() ES6 在Number对象上,新提供了Number.isFinite()和Number.isNaN()两个方法. Number.is ...

  8. webrtc 学习资源 http://www.cnblogs.com/lingyunhu/p/3578218.html

    Realtime/Working WebRTC Experiments It is a repository of uniquely experimented WebRTC demos; writte ...

  9. Object.prototype.constructor

    Returns a reference to the Object function that created the instance's prototype. 注意这个属性的值是函数本省的引用,而 ...

  10. 多线程辅助类-CountDownLatch的用法

    转自:http://www.iteye.com/topic/1002652 CountDownLatch,一个同步辅助类,在完成一组正在其他线程中执行的操作之前,它允许一个或多个线程一直等待. 主要方 ...