hdu_1159 LCS
来源:互联网 发布:js删除div 编辑:程序博客网 时间:2024/06/05 00:13
看到那些内存几千k的代码我就蛋疼~~一维数组不就够了吗?
#include<iostream>#include<string>using namespace std;char s[1024];int dp[1024];string a,b;int temp,tmax,t2;inline void init(){ memset(dp,0,sizeof(dp)); return ;}void dpstart(){ init(); for(int i=0;i<a.length();i++) { temp=0; for(int j=0;j<b.length();j++) { if(a[i]==b[j]) { t2=dp[j]; dp[j]=temp+1; if(t2 > temp) { temp=t2; } } else { if(dp[j]>temp) { temp=dp[j]; } } } } tmax=0; for(int i=0;i<b.length();i++) { if(dp[i]>tmax) { tmax=dp[i]; } } return ;}int main(){ while(scanf("%s",&s)!=EOF) { a=s; if(scanf("%s",&s)==EOF) { break; } else { b=s; } dpstart(); printf("%d\n",tmax); } return 0;}
- hdu_1159 LCS
- HDU_1159 Common Subsequence 【动态规划】
- LCS
- LCS
- lcs
- LCS
- LCS
- LCS
- LCS
- LCS
- LCS
- LCS
- lcs
- LCS
- LCS
- lcs
- LCS
- LCS
- 《Linux那些事儿之我是USB》我是U盘(30)彼岸花的传说(The End)
- 根据时间方式获取Sequence便于数据库操作
- 针对使用Spring框架开发的一个实例的知识总结
- python ftplib
- 数组的初始化
- hdu_1159 LCS
- static_cast、dynamic_cast、reinterpret_cast、和const_cast
- mysql的几条命令
- android Landscape模式下,禁止输入键盘全屏显示
- Latex 嵌套 表格 示例
- mysql 中的 in
- 建立双线服务器(双线游戏服务器)
- Linux关闭firewall和selinux操作命令
- 管理Linux交换分区