UVA 10405 Longest Common Subsequence
来源:互联网 发布:itools4.0官方下载mac 编辑:程序博客网 时间:2024/06/09 23:04
大意不再赘述。
思路:最长公共子序列。
吐槽一下,用scanf输入就WA,gets就AC,神马情况。。
#include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>#include <string>#include <algorithm>using namespace std;const int MAXN = 1010;char x[MAXN], y[MAXN];int d[MAXN][MAXN];void LCSlength(int n, int m){for(int i = 1; i <= n; i++) d[i][0] = 0;for(int i = 1; i <= m; i++) d[0][i] = 0;for(int i = 1; i <= n; i++)for(int j = 1; j <= m; j++){if(x[i-1] == y[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[n][m]);}int main(){while(gets(x)){gets(y);int n = strlen(x), m = strlen(y);LCSlength(n, m);}return 0;}
- 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
- 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
- 如何使用iOS Keychain存储用户敏感信息
- IOS----Core Animation介绍2
- 我在iteye上写blog
- IOS----Core Animation介绍3
- HULFT6を使用しております。
- UVA 10405 Longest Common Subsequence
- 唐朝七圣
- Python threading模块简介
- 软件开发与系统(CC2E)
- linux平台取CPUID
- 深圳宽带
- UVA 111 History Grading
- CC2e:《代码大全(第2版)》集萃
- Chain Of Responsibility(职责链)模式