POJ 1458
#include <iostream>
#include <string>
#define MAXN 1000 using namespace std; string s_1;
string s_2;
void init();
int _m[MAXN][MAXN];
void fun_lcs();
int main()
{
// freopen("acm.acm","r",stdin);
while(cin>>s_1>>s_2)
{
init();
fun_lcs();
cout<<_m[s_1.length()][s_2.length()]<<endl;
} return ;
} void init()
{
int i;
int j;
_m[][] = ;
for(i = ; i < s_1.length(); ++ i)
{
_m[i+][] = ;
}
for(j = ; j < s_2.length(); ++ j)
{
_m[][j+] = ;
}
} void fun_lcs()
{
int i;
int j;
for(i = ; i < s_1.length(); ++ i)
{
for(j = ; j < s_2.length(); ++ j)
{
if(s_1[i] == s_2[j])
{
_m[i+][j+] = _m[i][j] + ;
}
else
{
if(_m[i+][j] > _m[i][j+])
{
_m[i+][j+] = _m[i+][j];
}
else
{
_m[i+][j+] = _m[i][j+];
}
}
}
}
}
关注我的公众号,当然,如果你对Java, Scala, Python等技术经验,以及编程日记,感兴趣的话。

技术网站地址: vmfor.com
POJ 1458的更多相关文章
- LCS POJ 1458 Common Subsequence
题目传送门 题意:输出两字符串的最长公共子序列长度 分析:LCS(Longest Common Subsequence)裸题.状态转移方程:dp[i+1][j+1] = dp[i][j] + 1; ( ...
- POJ 1458 Common Subsequence(LCS最长公共子序列)
POJ 1458 Common Subsequence(LCS最长公共子序列)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?c ...
- POJ 1458 最长公共子序列(dp)
POJ 1458 最长公共子序列 题目大意:给出两个字符串,求出这样的一 个最长的公共子序列的长度:子序列 中的每个字符都能在两个原串中找到, 而且每个字符的先后顺序和原串中的 先后顺序一致. Sam ...
- POJ 1458 Common Subsequence (动态规划)
题目传送门 POJ 1458 Description A subsequence of a given sequence is the given sequence with some element ...
- POJ 1458 1159
http://poj.org/problem?id=1458 一道容易的DP,求最长公共子序列的 dp[i][j],代表str1中的第i个字母和str2中的第j个字母的最多的公共字母数 #includ ...
- OpenJudge/Poj 1458 Common Subsequence
1.链接地址: http://poj.org/problem?id=1458 http://bailian.openjudge.cn/practice/1458/ 2.题目: Common Subse ...
- poj 1458 Common Subsequence(区间dp)
题目链接:http://poj.org/problem?id=1458 思路分析:经典的最长公共子序列问题(longest-common-subsequence proble),使用动态规划解题. 1 ...
- (最长公共子序列 暴力) Common Subsequence (poj 1458)
http://poj.org/problem?id=1458 Description A subsequence of a given sequence is the given sequence w ...
- POJ 1458 Common Subsequence(最长公共子序列LCS)
POJ1458 Common Subsequence(最长公共子序列LCS) http://poj.org/problem?id=1458 题意: 给你两个字符串, 要你求出两个字符串的最长公共子序列 ...
- POJ 1458 Common Subsequence DP
http://poj.org/problem?id=1458 用dp[i][j]表示处理到第1个字符的第i个,第二个字符的第j个时的最长LCS. 1.如果str[i] == sub[j],那么LCS长 ...
随机推荐
- 使用MSYS2编译64位gvim
1. 下载安装MSYS2 在https://msys2.github.io/下载MSYS2,推荐下载x86-64版,此版本内置了MinGW32与MinGW64 安装后首先更新MSYS2系统,顺序执行下 ...
- Linux内核学习笔记——内核内存管理方式
一 页 内核把物理页作为内存管理的基本单位:内存管理单元(MMU)把虚拟地址转换为物理 地址,通常以页为单位进行处理.MMU以页大小为单位来管理系统中的也表. 32位系统:页大小4KB 64位系统:页 ...
- Mybatis typeAliases别名
<typeAliases> <typeAlias type="com.green.phonemanage.model.CellPhone" alias=" ...
- Javascript中“==”与“===”的区别
在Javascript中有"=="和"==="两种比较运行符,那么他们有什么区别呢? 一.对于string,number等基础类型,==和===是有区别的 1) ...
- IOS之表视图单元格删除、移动及插入
1.实现单元格的删除,实现效果如下 - (void)viewDidLoad { [super viewDidLoad]; //设置导航栏 self.editButtonItem.title = @&q ...
- 新手学Android
Eclipse平台下的新手Android学习记录. 1.打开一个本地的项目 在Project Explorer右键->Import->Existing Projects into Work ...
- SQLiteAPI函数详解
使用的过程根据使用的函数大致分为如下几个过程: sqlite3_open() sqlite3_prepare() sqlite3_step() sqlite3_column() sqlite3_fin ...
- ATR与ATS
ATR:answer to reset 复位应答 ATS:answer to select 选择应答
- jta.properties transactions.properties Log already in use 解决方法
当在resin里跑多个含有atomikos控制事物的项目时,会报错,Log already in use. 解决方法: 加jta.properties或者transactions.properties ...
- Understanding Convolutions【转】
Understanding Convolutions In a previous post, we built up an understanding of convolutional neural ...