Common Subsequence
#include<cstdio>
#include<iostream>
#include<cmath>
#include<string>
#include<cstring>
#include<algorithm>
using namespace std;
int a[][];
int main()
{
string s1,s2;
while(cin>>s1>>s2)
{
int k1=s1.length();
int k2=s2.length();
memset(a,,sizeof(a));
for(int i=; i<=k1; i++)
{
for(int j=; j<=k2; j++)
{
if(s1[i-]==s2[j-])
{
a[i%][j]=a[(i-)%][j-]+;
}
else
{
a[i%][j]=max(a[(i-)%][j],a[i%][j-]);
}
}
}
printf("%d\n",a[k1%][k2]);
}
return ;
}
Common Subsequence的更多相关文章
- 动态规划求最长公共子序列(Longest Common Subsequence, LCS)
1. 问题描述 子串应该比较好理解,至于什么是子序列,这里给出一个例子:有两个母串 cnblogs belong 比如序列bo, bg, lg在母串cnblogs与belong中都出现过并且出现顺序与 ...
- LintCode Longest Common Subsequence
原题链接在这里:http://www.lintcode.com/en/problem/longest-common-subsequence/ 题目: Given two strings, find t ...
- [UCSD白板题] Longest Common Subsequence of Three Sequences
Problem Introduction In this problem, your goal is to compute the length of a longest common subsequ ...
- LCS(Longest Common Subsequence 最长公共子序列)
最长公共子序列 英文缩写为LCS(Longest Common Subsequence).其定义是,一个序列 S ,如果分别是两个或多个已知序列的子序列,且是所有符合此条件序列中最长的,则 S 称为已 ...
- Longest Common Subsequence
Given two strings, find the longest common subsequence (LCS). Your code should return the length of ...
- LCS POJ 1458 Common Subsequence
题目传送门 题意:输出两字符串的最长公共子序列长度 分析:LCS(Longest Common Subsequence)裸题.状态转移方程:dp[i+1][j+1] = dp[i][j] + 1; ( ...
- Common Subsequence LCS
题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87730#problem/F 题目: Description A subsequ ...
- poj 1458 Common Subsequence
Common Subsequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 46387 Accepted: 19 ...
- Longest Increasing Common Subsequence (LICS)
最长上升公共子序列(Longest Increasing Common Subsequence,LICS)也是经典DP问题,是LCS与LIS的混合. Problem 求数列 a[1..n], b[1. ...
- Common Subsequence(dp)
Common Subsequence Time Limit: 2 Sec Memory Limit: 64 MBSubmit: 951 Solved: 374 Description A subs ...
随机推荐
- pandas对象保存到mysql出错提示“BLOB/TEXT column used in key specification without a key length”解决办法
问题 将DataFrame数据保存到mysql中时,出现错误提示: BLOB/TEXT column used in key specification without a key length 原因 ...
- Linux Shell编程学习笔记
打算在学习过程中将每个写过的程序一个个的往上贴; 2015-07-03 1. 鸟叔第三版13.2.1节“利用日期进行文件的创建” 源代码 #!/bin/bashPATH=/bin:/sbin:/usr ...
- 利用d3.js绘制雷达图
利用d3,js将数据可视化,能够做到数据与代码的分离.方便以后改动数据. 这次利用d3.js绘制了一个五维的雷达图.即将多个对象的五种属性在一张图上对照. 数据写入data.csv.数据类型写入typ ...
- hnsd11348tree(并查集)
Problem description A graph consists of a set of vertices and edges between pairs of vertices. Two v ...
- (黑客游戏)HackTheGame1.21 过关攻略
第一关: 标题 : 您好 来自 : chaozz@fake-mail-address.com ----------------------------------------------------- ...
- 笔试之Linux命令的使用
1. awk文本处理工具,显示ps的最后两列 ps -ef|awk '{print $1,$2}' 打印第一和第二域 $0是全域 2. Linux下查看内存使用情况 free
- Eclipse混淆文件导入Android Studio Gradle编译报input jar file is specified twice
Eclipse项目中的混淆配置文件 复制到AS中 在混淆的过程中提示如下错误 Error:Execution failed for task ':app:proguardDemoRelease ...
- IDL实现主成分变化(PCA)
IDL只能通过调用envi的二次接口做图像的变换,但是对于普通的数据没有提供函数.根据主成分变换的原理,用IDL写出来了,这样就不用每次再去用matlab的princomp去做了.主成分变化的基本过程 ...
- OD: Kernel Exploit - 1
第 22 章,内核漏洞利用技术 首先编写具有漏洞的驱动 exploitme.sys,再展开内核漏洞利用思路和方法: /***************************************** ...
- springmvc的渲染
1.1.1 支持绑定表单对象 我们先来看如下使用form标签的一个示例: Jsp代码 收藏代码 <form:form action="formTag/form.do" met ...