与 最长公共子序列类似 只是最长公共子串必须连续 所以只能走斜线!!!! ''' LCS 最长公共子序列 ''' def LCS_len(x, y): m = len(x) n = len(y) dp = [[0] * (n + 1) for i in range(m + 1)] B = [[' '] * (n + 1) for i in range(m + 1)] for i in range(1, m + 1): for j in range(1, n + 1): if x[i - 1] =…
uva 10066 The Twin Towers 标题效果:最长公共子. 解题思路:最长公共子. #include<stdio.h> #include<string.h> #include<stdlib.h> #include<algorithm> using namespace std; int a[105], b[105], dp[105][105]; int main() { int n, m, Case = 1; while (scanf(&quo…
#!一个序列S任意删除若干个字符得到的新序列T,则T叫做S的子序列 注意,这个和最长公共字串不一样,最长公共子串要求连续. 1.算法公式: def lcs(a,b): lena = len(a) lenb = len(b) c=[[0]*(lenb+1) for j in range(lena+1) ] flag = [[0]*(lenb+1) for j in range(lena+1) ] for i in range(lena+1)[1:]: for j in range (lenb+1)…
uva 10192 Vacation The Problem You are planning to take some rest and to go out on vacation, but you really don't know which cities you should visit. So, you ask your parents for help. Your mother says "My son, you MUST visit Paris, Madrid, Lisboa an…
AGTC Description Let x and y be two strings over some finite alphabet A. We would like to transform x into y allowing only operations given below: Deletion: a letter in x is missing in y at a corresponding position. Insertion: a letter in y is missin…
http://acm.hdu.edu.cn/showproblem.php?pid=1403 Longest Common Substring Time Limit: 8000/4000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3068 Accepted Submission(s): 1087 Problem Description Given two string…