HDU 5860 Death Sequence(递推) 题目链接http://acm.split.hdu.edu.cn/showproblem.php?pid=5860 Description You may heard of the Joseph Problem, the story comes from a Jewish historian living in 1st century. He and his 40 comrade soldiers were trapped in a cave…
题目的匹配应该也要看成一个文本串与另一个模式串的匹配过程 Text是以当前i结尾的后缀来匹配Pattern的前缀(非真) 这里的Pattern肯定是可以匹配成功的,直接由next来保证(next总是当前结尾的最大前缀,恰好满足递推的需要) (说的不是很准确,就是kmp匹配过程时使用的方法) 举个栗子: a b a b a c b a 0 0 1 2 3 0 0 1 next 1 1 1 1 1 1 1 1 dp 初始合法状态 1 1 2 2 3 1 1 2 dp 最终计算结果 dp[1] = 1…