poj 1458 Common Subsequence
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 46387 | Accepted: 19045 |
Description
Input
Output
Sample Input
abcfbc abfcab
programming contest
abcd mnp
Sample Output
4
2
0
Source
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
#define N 1010
char x[N],y[N];
short int f[N][N];
int main(){
while(scanf("%s%s",x+,y+)==){
int lx=strlen(x+),ly=strlen(y+);
for(int i=;i<=lx;i++)
for(int j=;j<=ly;j++)
if(x[i]==y[j])
f[i][j]=f[i-][j-]+;
else
f[i][j]=max(f[i-][j],f[i][j-]);
printf("%d\n",f[lx][ly]);
for(int i=;i<=lx;i++)for(int j=;j<=ly;j++)f[i][j]=;
}
return ;
}
poj 1458 Common Subsequence的更多相关文章
- 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 ...
- 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(最长公共子序列LCS)
POJ1458 Common Subsequence(最长公共子序列LCS) http://poj.org/problem?id=1458 题意: 给你两个字符串, 要你求出两个字符串的最长公共子序列 ...
- POJ 1458 Common Subsequence (动态规划)
题目传送门 POJ 1458 Description A subsequence of a given sequence is the given sequence with some element ...
- Poj 1458 Common Subsequence(LCS)
一.Description A subsequence of a given sequence is the given sequence with some elements (possible n ...
- poj 1458 Common Subsequence【LCS】
Common Subsequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 43132 Accepted: 17 ...
- (线性dp,LCS) POJ 1458 Common Subsequence
Common Subsequence Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 65333 Accepted: 27 ...
- POJ - 1458 Common Subsequence DP最长公共子序列(LCS)
Common Subsequence A subsequence of a given sequence is the given sequence with some elements (possi ...
随机推荐
- SharePoint部署工具SPSD
SharePoint Solution Deployer,绝对属于必备的SharePoint工具之一了. 下载,解压这个工具,会有如下的目录(没有Assemblies和DeployGAC.bat)解压 ...
- SharedPreference.Editor的apply和commit方法异同
这两个方法的区别在于: 1. apply没有返回值而commit返回boolean表明修改是否提交成功 2. apply是将修改数据原子提交到内存, 而后异步真正提交到硬件磁盘, 而commit是同步 ...
- DownloadManager 的使用
一.基本概念 1.DownloadManager是Android 2.3A (API level 9) 引入的,基于http协议,用于处理长时间下载. 2.DownloadManager对于断点 ...
- 内置对象Clob对从数据库表中取的字符大对象CLOB类型的列值进行读取操作
package readclobDemo.bao; import java.io.IOException; import java.io.Reader; import java.sql.Clob; i ...
- Git基本使用命令
整理Git的一些基本使用命令. # 1)克隆代码 boldseas@lian-PC MINGW64 /d/TestGroup $ git clone ssh://git@code.boldseas ...
- Effective Java 59 Avoid unnecessary use of checked exceptions
The burden is justified if the exceptional condition cannot be prevented by proper use of the API an ...
- 关于移动端的font和图片的问题
一.font-family 使用无衬线字体 body { font-family: "Helvetica Neue", Helvetica, STHeiTi, sans-serif ...
- SQL基础(2)-约束
1. 添加主键约束 a.创建表时添加主键(默认系统命名主键) create table pt_ticket_info( id varchar2(50) primary key not null, -- ...
- cocos2d-x之加法计算器
bool HelloWorld::init() { if ( !Layer::init() ) { return false; } Size visibleSize = Director::getIn ...
- Spring 下载与安装以及spring 3.2.9 jar包详解
一.Spring简介 Spring官网改版后,很多项目的完整zip包下载链接已经隐掉了,虽然Spring旨在引导大家用更“高大上”的maven方式来管理所依赖的jar包,但是完全没想到中国的国情,在 ...