E - Multiplication Puzzle
#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的更多相关文章
- poj 1651 Multiplication Puzzle (区间dp)
题目链接:http://poj.org/problem?id=1651 Description The multiplication puzzle is played with a row of ca ...
- POJ1651:Multiplication Puzzle(区间DP)
Description The multiplication puzzle is played with a row of cards, each containing a single positi ...
- ZOJ 1602 Multiplication Puzzle(区间DP)题解
题意:n个数字的串,每取出一个数字的代价为该数字和左右的乘积(1.n不能取),问最小代价 思路:dp[i][j]表示把i~j取到只剩 i.j 的最小代价. 代码: #include<set> ...
- POJ 1651 Multiplication Puzzle (区间DP)
Description The multiplication puzzle is played with a row of cards, each containing a single positi ...
- Poj 1651 Multiplication Puzzle(区间dp)
Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 10010 Accepted: ...
- POJ 1651 Multiplication Puzzle(类似矩阵连乘 区间dp)
传送门:http://poj.org/problem?id=1651 Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65536K T ...
- Multiplication Puzzle ZOJ - 1602
Multiplication Puzzle ZOJ - 1602 传送门 The multiplication puzzle is played with a row of cards, each c ...
- POJ1651 Multiplication Puzzle —— DP 最优矩阵链乘 区间DP
题目链接:https://vjudge.net/problem/POJ-1651 Multiplication Puzzle Time Limit: 1000MS Memory Limit: 65 ...
- xtu read problem training 4 B - Multiplication Puzzle
Multiplication Puzzle Time Limit: 1000ms Memory Limit: 65536KB This problem will be judged on PKU. O ...
- 题解【POJ1651】Multiplication Puzzle
Description The multiplication puzzle is played with a row of cards, each containing a single positi ...
随机推荐
- Thumbelina,摘自iOS应用Snow White and more stories
Once upon a time there was a woman who wanted to have a child. 从前,有个想要个孩子的女人. A witch heard her wish ...
- Javascript学习之Date对象详解
1.定义 创建 Date 实例用来处理日期和时间.Date 对象基于1970年1月1日世界协调时起的毫秒数 2.语法 构造函数 new Date() new Date(value) value代表自世 ...
- ABAP 取字段的简短描述
取字段的简短描述: 取字段描述 DATA inttab LIKE STANDARD TABLE OF dfies WITH HEADER LINE. CALL FUNCTION 'DDIF_FIELD ...
- appium(5)-Appium capabilities
Appium Capabilities Appium server capabilities Capability Description Values automationName Which au ...
- ubuntu搭建nginx
1.下载nginx压缩包 2.上传.解压 tar -zxvf nginx-1.8.0.tar.gz cd nginx-1.8.0 3.安装 make install 4.启动,停止 ,重启 服务 可 ...
- Double.valueOf()与Double.parseDouble()两者的区别
写代码用到这两个方法,不知道有什么区别,看一下源码: Double.parseDouble(String str) public static double parseDouble(String s) ...
- mysql 数据库电脑间迁移
应用实例: database1(简称DB1)保存在PC1中的MySQL中,需要将DB1迁移到PC2中的MySQL中 环境: win7 MySQL5.7.13 参考: http://stackoverf ...
- linux下实现目录即文件的完整删除
功能: 1.删除目录 2.删除文件 3.删除不为空的目录即下属文件 #ifndef _DELETE_FILE #define _DELETE_FILE #include <sys/stat.h& ...
- android jni下c文件怎么输出logcat
#include <android/log.h> #define LOG_TAG "clog"#define LOGD(...) __android_log_print ...
- PHP错题误区
1,$bool = TRUE;echo gettype($bool); //这个输出类型:booleanecho is_string($bool); //这个用echo是不能输出布尔型的,只有va ...