Save the game has less than 50 days, their own DP this piece is really weak, ready to take some days of the mad brush dp.
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem= 1346
To find the longest common subsequence of a two string.
Train of thought: water problem, but need to notice is the string may appear space, need to use gets, really pit.
More Wonderful content: http://www.bianceng.cnhttp://www.bianceng.cn/Programming/sjjg/
#include <stdio.h> #include <string.h> #define MAX (A, b) a>b?a:b Char s1[1010], s2[1010]; int dp[1
010][1010];
int main () {while (gets (S1)) {gets (S2);
memset (DP, 0, sizeof (DP));
int len1 = strlen (S1);
int len2 = strlen (s2); for (int i = 1; I <= len1. ++i) {for (int j = 1; j <= Len2; ++j) {if
(S1[i-1] = = S2[j-1])
{Dp[i][j] = dp[i-1][j-1]+1;
else {Dp[i][j] = max (Dp[i-1][j], dp[i][j-1]);
} printf ("%d\n", Dp[len1][len2]);
return 0; } accepted