LCS

//Writer:GhostCai && His Yellow Duck

#include<iostream>
#include<cstring>
#define MAXN 5000
using namespace std; char s[MAXN],t[MAXN];
int lens,lent;
int f[MAXN][MAXN]; int main() {
cin>>s+1>>t+1;
memset(f,0,sizeof(f));
lens=strlen(s+1);
lent=strlen(t+1);
for(int i=1; i<=lens; i++) {
for(int j=1; j<=lent; j++) {
if(s[i]==t[j]) {
f[i][j]=f[i-1][j-1]+1;
} else {
f[i][j]=max(f[i-1][j],f[i][j-1]);
}
}
}
cout<<f[lens][lent]<<endl; return 0;
}

最新文章

  1. GPS部标平台的架构设计(十)-基于Asp.NET MVC构建GPS部标平台
  2. java插入排序
  3. ASP.NET常用的SqlDbHelper类
  4. 泛函编程(26)-泛函数据类型-Monad-Applicative Functor Traversal
  5. smaller programs should improve performance
  6. 使用Spring的jdbcTemplate进一步简化JDBC操作
  7. C# 设置程序开机自动运行(+注册表项)
  8. 很全的corel图像分类,场景识别图像库
  9. Codeforces Round #321 (Div. 2) E. Kefa and Watch 线段树hash
  10. [LeetCode]题解(python):126-Word Ladder II
  11. PHP学习之-数据库操作
  12. C++如何入门
  13. KICKSTART无人值守安装
  14. multi-label image classification:多标签图像分类总结
  15. 【Apache Pulsar】Apache Pulsar单机环境及Go语言开发环境搭建
  16. Linux查找当前目录5天的文件并打包
  17. python 读写json数据
  18. Python3.5 学习二十四
  19. python-day33--Process类中的方法及属性
  20. PHP性能调优,PHP慢日志---善用php-fpm的慢执行日志slow log,分析php性能问题

热门文章

  1. File upload in ASP.NET Core web API
  2. MyBatis嵌套Collection
  3. VLAN-4-在路由器上配置Trunk
  4. [软件工程基础]2017.10.31 第四次 Scrum 会议
  5. php post提交超过1000个字段的时候服务器会截断多余部分
  6. ubuntu触摸板关闭开启
  7. SpringBoot项目取消数据库配置
  8. 编译运行第一个Java程序——通过示例学习Java编程3
  9. 自定义消息中如果需要定义WPARAM和LPARAM,该怎么使用和分配?
  10. Ubuntu安装新英伟达驱动出现问题解决方法