10405 - Longest Common Subsequence
来源:互联网 发布:python innertext 编辑:程序博客网 时间:2024/05/01 08:03
动态规划的入门题,求最长公共子序列
# include<stdio.h># include<string.h>int max(int a,int b);int d[1005][1005];char str1[1005],str2[1005];int main(){while(gets(str1)&&gets(str2)){ memset(d,0,sizeof(d)); int len1=strlen(str1); int len2=strlen(str2); for(int i=1;i<=len1;i++) { for(int j=1;j<=len2;j++) { if(str1[i-1]==str2[j-1])d[i][j]=d[i-1][j-1]+1; else { d[i][j]=max(d[i-1][j],d[i][j-1]); } } } printf("%d\n",d[len1][len2]);}return 0;}int max(int a,int b){int ans=(a > b ? a:b);return ans;}
0 0
- 10405 Longest Common Subsequence
- 10405 - Longest Common Subsequence
- 10405 - Longest Common Subsequence
- 10405 - Longest Common Subsequence
- 10405 - Longest Common Subsequence
- 10405 - Longest Common Subsequence
- UVa 10405 Longest Common Subsequence
- Uva 10405 Longest Common Subsequence
- UVA 10405 - Longest Common Subsequence
- UVa 10405 - Longest Common Subsequence
- UVA 10405 Longest Common Subsequence
- uva 10405 Longest Common Subsequence
- uva 10405 - Longest Common Subsequence
- UVA 10405 Longest Common Subsequence
- UVa 10405 - Longest Common Subsequence
- UVA 10405 Longest Common Subsequence
- Uva - 10405 - Longest Common Subsequence
- UVa 10405 - Longest Common Subsequence
- linux sleep函数
- [转]U_boot 的 bootcmd 和bootargs参数详解
- 继承、封装、多态
- signer information does not match signer information of other classes in the same package
- 更改printk打印级别
- 10405 - Longest Common Subsequence
- 使用SVN 提交SO库等文件
- 关于PIN码校验的Timing攻击及解决方案
- 【黑马程序员】接口
- 重要工作文件误删除怎么找回呢
- 学会有效地投资,无论工资多少
- 基本排序
- IE9卸载后无法安装的解决办法
- PHP 实现定时任务的几种方法