
动态规划
winycg
问题可联系QQ:1241981936
展开
-
最长递增子序列问题
设L=<a1,a2,…,an>是n个不同的实数的序列,L的递增子序列是这样一个子序列Lin=<aK1,ak2,…,akm>,其中k1<k2<…<km且aK1<ak2<…<akm。求最大的m值,即子序列的最大长度原创 2016-03-06 19:40:03 · 541 阅读 · 0 评论 -
fzuoj 2218 Simple String Problem(状态压缩dp)
Recently, you have found your interest in string theory. Here is an interesting question about strings.You are given a string S of length n consisting of the first k lowercase letters.You are re原创 2017-04-16 19:37:52 · 582 阅读 · 0 评论 -
矩阵链乘法确定矩阵的最佳计算顺序
对于4个矩阵的乘法:A * B * C * D 20*2 2*30 30*12 12*8由于矩阵的乘法无关紧要,对上述的乘法可以产生5种不同的顺序,每一种顺序的乘法次数如下:A(B(CD)):3680(AB)(CD):8880A((BC)D):1232((AB)C)D:10320(A(BC))D:3120设m[原创 2017-03-30 23:24:39 · 12070 阅读 · 2 评论 -
背包基础问题
01背包(ZeroOnePack):有N件物品和一个容量为V的背包。(每种物品均只有一件)第i件物品的费用是c[i],价值是w[i]。求解将哪些物品装入背包可使价值总和最大。4件物品,重量和价值如下,背包的重量为10,物品情况w5463v10403050//W[i]表示重量,v[i]表示价值原创 2017-02-06 22:35:24 · 453 阅读 · 0 评论 -
Huffman编码-石子问题+平行四边形优化
基础版:有N堆石子,现要将石子有序的合并成一堆,规定如下:每次只能移动任意的2堆石子合并,合并花费为将的一堆石子的数量。设计一个算法,将这N堆石子合并成一堆的总花费最小(或最大)。解法:使用贪心即可相邻版:在一条直线上摆着N堆石子,现要将石子有序的合并成一堆,规定如下:每次只能移动相邻的2堆石子合并,合并花费为将的一堆石子的数量。设计一个算法,将这N堆石子合并成一堆的总原创 2017-03-02 17:04:29 · 1394 阅读 · 0 评论 -
状态压缩dp入门--------TSP问题
TSP问题给你n个城市和城市之间的通路的长度,请你找出一条经过所有城市一次且仅经过一次的路线,使得这条路线的长度最短。问题分析,如果要设计一个状态的话,显然状态与已经走过的城市和你当前所在的城市有关,现在,按照一定的顺序给每个城市一个编号,如果已经走过的城市记为1,没走过的城市记为0,那么已经走过的城市的状态就可以压缩成一个数。所以,该题目的状态表示为:dp[i][j]表示分析在当原创 2016-10-06 12:19:06 · 1823 阅读 · 1 评论 -
背包问题拓展应用
FZU 2214Given a set of n items, each with a weight w[i] and a value v[i], determine a way to choose the items into a knapsack so that the total weight is less than or equal to a given limit B原创 2017-02-09 00:36:48 · 931 阅读 · 0 评论 -
区间dp----整数划分nyoj746
问题是我们经常见到的整数划分,给出两个整数 n , m ,要求在 n 中加入m - 1 个乘号,将n分成m段,求出这m段的最大乘积输入第一行是一个整数T,表示有T组测试数据接下来T行,每行有两个正整数 n,m ( 1输出输出每组测试样例结果为一个整数占一行样例输入2111 21111 2样例输出11121a[i][j]原创 2016-09-21 23:42:20 · 477 阅读 · 0 评论 -
第7届山东省赛----sdut 3565 Feed the monkey
Problem DescriptionAlice has a monkey, she must feed fruit to the monkey every day.She has three kinds of fruits, bananas, peaches and apples. Every day, she chooses one in three, and pick one o原创 2016-10-10 20:02:45 · 889 阅读 · 0 评论 -
hdu 5795 最长公共子序列的应用-----公共子序列的个数
DescriptionAlice gets two sequences A and B. A easy problem comes. How many pair of sequence A' and sequence B' are same. For example, {1,2} and {1,2} are same. {1,2,4} and {1,4,2} are not same. A原创 2016-08-26 21:49:54 · 695 阅读 · 0 评论 -
hdu 5773 最长递增子序列的应用---随意改变为0的数
Description?? gets an sequence S with n intergers(0 < n <= 100000,0<= S[i] <= 1000000).?? has a magic so that he can change 0 to any interger(He does not need to change all 0 to the same interger)原创 2016-08-26 21:03:14 · 812 阅读 · 0 评论 -
最长非递减子序列的应用
Description我们有一个数列A1,A2...An,你现在要求修改数量最少的元素,使得这个数列严格递增。其中无论是修改前还是修改后,每个元素都必须是整数。 请输出最少需要修改多少个元素。Input第一行输入一个$T (1 \leq T \leq 10)$,表示有多少组数据 每一组数据: 第一行输入一个$N (1 \leq N \leq原创 2016-08-22 22:40:36 · 1453 阅读 · 0 评论 -
hdu 1520 树形dp的应用
DescriptionThere is going to be a party to celebrate the 80-th Anniversary of the Ural State University. The University has a hierarchical structure of employees. It means that the supervisor rela原创 2016-08-25 21:07:40 · 542 阅读 · 0 评论 -
hdu 斜率dp
Problem DescriptionZero has an old printer that doesn't work well sometimes. As it is antique, he still like to use it to print articles. But it is too old to work for a long time and it will certai原创 2016-05-24 21:08:35 · 465 阅读 · 0 评论 -
fzu 2219 Huffman应用(贪心+优先队列)
ZB loves playing StarCraft and he likes Zerg most!One day, when ZB was playing SC2, he came up with an idea:He wants to change the queen's ability, the queen's new ability is to choose a worker原创 2017-04-16 20:53:45 · 617 阅读 · 0 评论