#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中使用大漠插件

    打开Class Wizard,Add Class...->MFC Class From TypeLib... File->Location->>> Finish-> ...

  2. UIButton的selected设为TRUE时在按下时显示自己定义的背景图

    在UIButton的selected设为TRUE后.须要在按钮高亮时,显示自己定义的背景图. 经研究hightLighted和selected这两个状态是能够重叠的,就是button能够同一时候处于s ...

  3. Struts多个文件上传

    Struts2多个文件上传 10级学员 韩晓爽课堂笔记 多个文件上传分为List集合和数组,下面我们着重介绍一下list集合的上传.都大同小异. 一 介绍 1. 在struts2文件上传的时候要先导入 ...

  4. codeforces 509 B题 Painting Pebbles

    转载地址:http://blog.csdn.net/nike0good/article/details/43449739 B. Painting Pebbles time limit per test ...

  5. Memory Notification: Library Cache Object loaded into SGA

    问题现象: 数据库服务器可以ping通,但SSH连接不了:应用.plsqldeveloper 也都连接不了.事情到了这个地步,只能重启服务器. 服务器环境:oracle10.2.0.1 +rhel5. ...

  6. CyclicBarrier及CountDownLatch的使用

    CountDownLatch位于java.util.concurrent包下,是JDK1.5的并发包下的新特性. 首先根据Oracle的官方文档看看CountDownLatch的定义: A synch ...

  7. linguistic相关

    Knowing a word means knowing both its sound and its meaning, while being able to use a word requires ...

  8. nginx开发_ngx_http_script源码解析

    功能简介 nginx中有很多配置项支持以变量的形式存在,在运行时根据实时值进行处理.例如如下配置: location / { sub_filter '<a href="http://1 ...

  9. 【USACO】Dining

    [题目链接] [JZXX]点击打开链接 [caioj]点击打开链接 [算法] 拆点+网络流 [代码] #include<bits/stdc++.h> using namespace std ...

  10. SQL Server中误删除数据的恢复

    SQL Server中误删除数据的恢复本来不是件难事,从事务日志恢复即可.但是,这个恢复需要有两个前提条件: 1. 至少有一个误删除之前的数据库完全备份. 2. 数据库的恢复模式(Recovery m ...