随笔分类 -  动态规划

摘要:一个N*N矩阵中有不同的正整数,经过这个格子,就能获得相应价值的奖励,从左上走到右下,只能向下向右走,求能够获得的最大价值。 例如:3 * 3的方格。 1 3 3 2 1 3 2 2 1 能够获得的最大价值为:11。 一个N*N矩阵中有不同的正整数,经过这个格子,就能获得相应价值的奖励,从左上走到右 阅读全文
posted @ 2017-07-29 17:09 wydxry 阅读(229) 评论(0) 推荐(0)
摘要:一个高度为N的由正整数组成的三角形,从上走到下,求经过的数字和的最大值。 每次只能走到下一层相邻的数上,例如从第3层的6向下走,只能走到第4层的2或9上。 5 8 4 3 6 9 7 2 9 5 例子中的最优方案是:5 + 8 + 6 + 9 = 28 一个高度为N的由正整数组成的三角形,从上走到下 阅读全文
posted @ 2017-07-29 16:20 wydxry 阅读(210) 评论(0) 推荐(0)
摘要:There is an old stone game.At the beginning of the game the player picks n(1<=n<=50000) piles of stones in a line. The goal is to merge the stones in 阅读全文
posted @ 2017-07-27 10:05 wydxry 阅读(305) 评论(0) 推荐(0)
摘要:Alex doesn't like boredom. That's why whenever he gets bored, he comes up with games. One long winter evening he came up with a game and decided to pl 阅读全文
posted @ 2017-07-26 18:38 wydxry 阅读(370) 评论(0) 推荐(0)
摘要:M * N的方格,一个机器人从左上走到右下,只能向右或向下走。有多少种不同的走法?由于方法数量可能很大,只需要输出Mod 10^9 + 7的结果。 M * N的方格,一个机器人从左上走到右下,只能向右或向下走。有多少种不同的走法?由于方法数量可能很大,只需要输出Mod 10^9 + 7的结果。 M 阅读全文
posted @ 2017-07-26 14:33 wydxry 阅读(211) 评论(0) 推荐(0)
摘要:给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为: abcicba abdkscab ab是两个串的子序列,abc也是,abca也是,其中abca是这两个字符串最长的子序列。 给出两个字符串A B,求A与B的最长公共子序列(子序列不要求是连续的)。 比如两个串为 阅读全文
posted @ 2017-07-26 10:08 wydxry 阅读(298) 评论(0) 推荐(0)
摘要:We are all familiar with sorting algorithms: quick sort, merge sort, heap sort, insertion sort, selection sort, bubble sort, etc. But sometimes it is 阅读全文
posted @ 2017-07-26 09:37 wydxry 阅读(243) 评论(0) 推荐(0)
摘要:A numeric sequence of ai is ordered if a1 < a2 < ... < aN. Let the subsequence of the given numeric sequence ( a1, a2, ..., aN) be any sequence ( ai1, 阅读全文
posted @ 2017-07-26 09:34 wydxry 阅读(185) 评论(0) 推荐(0)
摘要:A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = <x1, x2, ..., xm> another se 阅读全文
posted @ 2017-07-26 09:32 wydxry 阅读(273) 评论(0) 推荐(0)
摘要:编辑距离,又称Levenshtein距离(也叫做Edit Distance),是指两个字串之间,由一个转成另一个所需的最少编辑操作次数。许可的编辑操作包括将一个字符替换成另一个字符,插入一个字符,删除一个字符。 例如将kitten一字转成sitting: sitten (k->s) sittin ( 阅读全文
posted @ 2017-07-26 09:09 wydxry 阅读(322) 评论(0) 推荐(0)
摘要:给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的) 例如:5 1 6 8 2 4 5 10,最长递增子序列是1 2 4 5 10。 给出长度为N的数组,找出这个数组的最长递增子序列。(递增子序列是指,子序列的元素是递增的) 例如:5 1 6 8 2 4 5 1 阅读全文
posted @ 2017-07-25 19:31 wydxry 阅读(346) 评论(0) 推荐(0)

Live2D