随笔分类 -  Algorithm

摘要:看过《算法导论》的人应该知道,动态规划中一个非常经典的例子就是LCS(Longest Common Length)最长公共子序列问题。下面我们来回顾一下LCS的概念。 假设有两个字符串,X=<A, B, C, B, D, A, B>,Y=<B, D, C, A, B, A>,那么它们的最长公共子序列为<B, C, B, A>,它的特点在于每个字符可以不连续。LCS问题在实际中也有非常多的应用,比如说用于论文查重等。 都说表达一个动态规划算法的精髓在于状态转移方程,那么我们就顺便回忆一下LCS的状态转移方程吧。如果用c[i, j]来表示序列Xi和Yi的LCS的 阅读全文
posted @ 2012-10-30 21:16 ErinFlyingFish 阅读(6121) 评论(1) 推荐(1) 编辑
摘要:Problem DescriptionIn this problem, your task is to calculate SUM(n) = 1 + 2 + 3 + ... + n.InputThe input will consist of a series of integers n, one integer per lineOutputFor each case, output SUM(n) in one line, followed by a blank line. You may assume the result will be in the range of 32-bit sig 阅读全文
posted @ 2011-07-20 17:04 ErinFlyingFish 阅读(15151) 评论(4) 推荐(2) 编辑

点击右上角即可分享
微信分享提示