#1636 : Pangu and Stones 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 In Chinese mythology, Pangu is the first living being and the creator of the sky and the earth. He woke up from an egg and split the egg into two parts: the sky and the earth. At the begi…
Blocks Time Limit: 5000MS Memory Limit: 65536K Total Submissions: 4250 Accepted: 1704 Description Some of you may have played a game called 'Blocks'. There are n blocks in a row, each box has a color. Here is an example: Gold, Silver, Silver, Sil…
题意 : 设 NUM 是一个 n 位十进制整数.如果将 NUM 划分为 k 段,则可得到 k 个整数.这 k 个整数的乘积称为 NUM 的一个 k 乘积.试设计一个算法,对于给定的 NUM 和 k,求出 NUM 的最大 k 乘积 分析 : 定义 dp[i][j] = 前 i 个数字中间插入 j 个乘号时候的最大乘积是多少 初始化 dp[ i ][ 0 ] = NUM(1, i) 1 <= i <= len(NUM) 最后的结果则存于 dp[n][k] 状态转移方程为 dp[i][j] = m…
题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1021 经典区间dp,dp[i][j] 表示将从 i 到 j 堆石子合并最小代价,长度为 j-i+1,可看做之前已经合并的 i 到 k 和 k 到 j 两堆石子合并,代价是 i 到 j 的石子数量: #include<iostream> #include<cstring> #include<algorithm> using namesp…
题解报告:poj 2955 Brackets(括号匹配) Description We give the following inductive definition of a “regular brackets” sequence: the empty sequence is a regular brackets sequence, if s is a regular brackets sequence, then (s) and [s] are regular brackets sequen…
区间类动态规划 一.基本概念 区间类动态规划是线性动态规划的拓展,它在分阶段划分问题时,与阶段中元素出现的顺序和由前一阶段的那些元素合并而来由很大的关系.例如状态f [ i ][ j ],它表示以已合并的次数为阶段,以区间的左端点 i 为状态,它的值取决于第 i 个元素和第 j 个元素断开的位置 k,即 f [ i ][ k ] + f [ k+1 ][ j ]的值.这一类型的动态规划,阶段特征非常明显,求最优值时需要预先设置阶段内的区间统计值,还要以动态规划的起始位置来判断. 区间类动态规划…