multiplication_puzzle(区间dp)
You Are the One
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 6706 Accepted Submission(s): 3339
The next n line are n integer D1-Dn means the value of diaosi of boys (0 <= Di <= 100)
5
1
2
3
4
5
5
5
4
3
2
2
Case #2: 24
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; const int maxn = + , inf = 0x3f3f3f3f; int n, value[maxn]; int dp[maxn][maxn]; int main() {
scanf("%d", &n);
for(int i = ; i <= n; i ++) {
scanf("%d", &value[i]);
}
for(int len = ; len < n; len ++) {
for(int i = ; i + len <= n; i ++) {
int j = i + len;
dp[i][j] = inf;
for(int k = i + ; k < j; k ++) {
dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j] + value[i] * value[k] * value[j]);
}
}
}
printf("%d\n", dp[][n]);
return ;
}
multiplication_puzzle(区间dp)的更多相关文章
- 【BZOJ-4380】Myjnie 区间DP
4380: [POI2015]Myjnie Time Limit: 40 Sec Memory Limit: 256 MBSec Special JudgeSubmit: 162 Solved: ...
- 【POJ-1390】Blocks 区间DP
Blocks Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 5252 Accepted: 2165 Descriptio ...
- 区间DP LightOJ 1422 Halloween Costumes
http://lightoj.com/volume_showproblem.php?problem=1422 做的第一道区间DP的题目,试水. 参考解题报告: http://www.cnblogs.c ...
- BZOJ1055: [HAOI2008]玩具取名[区间DP]
1055: [HAOI2008]玩具取名 Time Limit: 10 Sec Memory Limit: 162 MBSubmit: 1588 Solved: 925[Submit][Statu ...
- poj2955 Brackets (区间dp)
题目链接:http://poj.org/problem?id=2955 题意:给定字符串 求括号匹配最多时的子串长度. 区间dp,状态转移方程: dp[i][j]=max ( dp[i][j] , 2 ...
- HDU5900 QSC and Master(区间DP + 最小费用最大流)
题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5900 Description Every school has some legends, ...
- BZOJ 1260&UVa 4394 区间DP
题意: 给一段字符串成段染色,问染成目标串最少次数. SOL: 区间DP... DP[i][j]表示从i染到j最小代价 转移:dp[i][j]=min(dp[i][j],dp[i+1][k]+dp[k ...
- 区间dp总结篇
前言:这两天没有写什么题目,把前两周做的有些意思的背包题和最长递增.公共子序列写了个总结.反过去写总结,总能让自己有一番收获......就区间dp来说,一开始我完全不明白它是怎么应用的,甚至于看解题报 ...
- Uva 10891 经典博弈区间DP
经典博弈区间DP 题目链接:https://uva.onlinejudge.org/external/108/p10891.pdf 题意: 给定n个数字,A和B可以从这串数字的两端任意选数字,一次只能 ...
随机推荐
- react -搭建服务-2
export const DEFAULT_TITLE = "你好"; // export const PRODUCT_SERVER_URL = "http://10.10 ...
- cdh搭建仓库
搭建内部仓库使用yum安装cm Creating a Permanent Internal Repository 1,安装httpd yum install httpd 删除/etc/httpd/co ...
- Springboot设置session超时时间
按优先级高到低说: 第一种: spring boot 启动类里面: package com.mycenter; import org.mybatis.spring.annotation.MapperS ...
- [深度学习] pytorch学习笔记(1)(数据类型、基础使用、自动求导、矩阵操作、维度变换、广播、拼接拆分、基本运算、范数、argmax、矩阵比较、where、gather)
一.Pytorch安装 安装cuda和cudnn,例如cuda10,cudnn7.5 官网下载torch:https://pytorch.org/ 选择下载相应版本的torch 和torchvisio ...
- hdu 1796 How many integers can you find 容斥第一题
How many integers can you find Time Limit: 12000/5000 MS (Java/Others) Memory Limit: 65536/32768 ...
- TTTTTTTTTTTTTT CF 645D 点的优先级
题意:给你n个节点,m对优先级关系,a[i] b[i]代表a[i]的优先级比b[i]高,现在问你至少需要前多少对关系就能确定所有节点的优先级: #include <iostream> #i ...
- 16位masm汇编实现记忆化递归搜索斐波那契数列第50项
.model small ;递归fib,使用压缩BCD码,小端派 .data y1 byte 6 dup(0) y2 byte 6 dup(0) vis byte 1,1,1,61 dup(0) ;便 ...
- JavaWeb_Ajax通过JQuery和原生js异步传输数据
菜鸟教程 传送门 AJAX 优点:在不重新加载整个页面的情况下,可以与服务器交换数据并更新部分网页内容 XMLHttpRequest 对象 传送门 (一) [JQuery]定时发送ajax请求 (二) ...
- git介绍以及一些常用命令,加上vim编辑器的简单使用
https://www.jianshu.com/p/04a6517869b4 vim:进入vim编辑器,如果后接文件名,则进入该文件的编辑模式,看图:①.vim编辑器中,按i进入编辑模式:②.按Esc ...
- 关于MySQL 处理重复数据
统计重复数据 以下我们将统计表中 first_name 和 last_name的重复记录数: mysql> SELECT COUNT(*) as repetitions, last_name, ...