HDU 1159 Common Subsequence(dp LCS)

Problem Description A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X = another sequence Z = is a subsequence of X if there exists a strictly increasing sequence of indices of X such that for all j = 1,2,...,k, xij = zj. For example, Z = is a subsequence of X = with index sequence . Given two sequences X and Y the problem is to find the length of the maximum-length common subsequence of X and Y.
The program input is from a text file. Each data set in the file contains two strings representing the given sequences. The sequences are separated by any number of white spaces. The input data are correct. For each set of data the program prints on the standard output the length of the maximum-length common subsequence from the beginning of a separate line.

Sample Input

abcfbc abfcab programming contest abcd mnp

Sample Output

4 2 0

Source Southeastern Europe 2003

最长公共子序列

#include #include #include using namespace std; int max(int a,int b) { return a>b? a:b; } char a[1001],b[1001]; int dp[1000][1000]; int main() { while(scanf("%s%s",a,b)!=EOF) { int lena=strlen(a); int lenb=strlen(b); int i; for(i=0;i

点击复制链接 与好友分享!回本站首页
您对本文章有什么意见或着疑问吗?请到论坛讨论您的关注和建议是我们前行的参考和动力
上一篇:基于单个 div 的 CSS 绘图
下一篇:TMS320F28335项目开发记录2_CCS与仿真器连接问题
相关文章

NOJ[1093] HTML 即HDU1088 对字符串

图文推荐

HDU 1159 Common Subsequence(dp LCS)
CSS高效开发实战:CSS
CSS3实战开发: 纯CS
CSS3实战开发:手把手
CSS3实战开发:手把手

分类:默认分类 时间:2015-03-03 人气:8
本文关键词:
分享到:

相关文章

Copyright (C) quwantang.com, All Rights Reserved.

趣玩堂 版权所有 京ICP备15002868号

processed in 0.105 (s). 10 q(s)