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 ...
随机推荐
- idoc 和 bapi 和 rfc 之间的区别
se37 写出来的叫function,其中可以远程调用的叫rfc,remote-enabled function,abap语法和输入输出参数就会有一些限制.bapi是sap做好的实现特定业务操 ...
- Sharepoint学习笔记—习题系列--70-573习题解析 -(Q32-Q34)
Question 32You create a custom Web Part.You need to ensure that a custom property is visible in Edit ...
- android view holder 优化
android 一般都用viewholder来优化contentView,采用sparseArray能够进一步优化 /** * 用法: ImageView bananaView = ViewHolde ...
- 【原】自定义UINavigationItem的两种方法以及相应的隐藏方法
第一种: UIImage *searchimage=[UIImage imageNamed:@"search.png"]; UIBarButtonItem *barbtn=[[[U ...
- iOS NSDate、NSCalendar、NSDateComponents
时间解析(NSDate.NSCalendar.NSDateComponents): 1.使用NSCalendar和NSDateComponents解析日期,直接获取到年月日时分秒.获取到年月日时分秒其 ...
- JQuery判断radio是否选中,获取选中值
本文摘自:http://www.cnblogs.com/xcj1989/archive/2011/06/29/JQUERY_RADIO.html /*----------------------- ...
- Node.js之Promise维护(同步)多个回调(异步)状态
金天:学习一个新东西,就要持有拥抱的心态,如果固守在自己先前的概念体系,就会有举步维艰的感觉..NET程序员初用node.js最需要适应的就是异步开发, 全是异步,常规逻辑下遍历列表都是异步,如何保证 ...
- TCP 连接的 TIME_WAIT 过多 导致 Tomcat 假死
最近系统二次开发之后,发现使用的 Tomcat 7 会经常假死.前端点击页面无任何反应,打开firebug,很多链接一直在等待服务器的反应.查看服务器的状态,CPU占用很少,最多不超过10%,一般只有 ...
- SQL中获取最近的N个半年度
直接上代码: --获取往前推的N个半年度 CREATE FUNCTION F3_GetRecentNHalfYear ( @N INT ) RETURNS @Result TABLE ( Year S ...
- uname
uname uname用于打印操作系统和硬件架构相关的信息,对于可能在多个系统或架构上运行的Shell脚本程序很有用, 缺省选项相当于 -s 或--system $uname [-amnrsvpio] ...