Algorithm Design Example: Longest Common subsequence (DP) memory limit: 65536KB time limit: 500 MSaccept: 50 submit: 124 Description the subsequence of a given sequence is obtained after several elements are deleted from the sequence. To be exact, if the given sequence X = {x1, x2 ,..., Xm}, then another sequence Z = {z1, z2 ,..., Zk}, the subsequence of X refers to the existence of a strictly incrementing subscript sequence {i1, i2 ,..., Ik}, so that for all j = 1, 2 ,..., K, zj = xij provides two character sequences X and Y, and obtains their longest common subsequences. The number of Input first behavior test samples T (T <40), followed by T test samples. The first line of each test sample is string X, and the second line is string Y. X and Y only contain uppercase letters and cannot exceed 1000 characters in length. Output corresponds to the Output line of each test sample, with only one integer representing the length of the longest common subsequence of string X and string Y. Sample Input 2 ABCDEACEAAABBBCCCAABBCCSample Output 36 Author Eapink & CYL solution: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 28 29 30 31 32 33 34 35 36 37 # include <iostream> # include <string. h >#define N 1000 int dp [N] [N]; int max (int a, int B) {return a> B? A: B;} int main () {int I, j, k, len1, len2, textNum; char s1 [N], s2 [N]; scanf ("% d", & textNum); for (k = 0; k <textNum; k ++) {scanf ("% s", s1, s2 ); len1 = strlen (s1); len2 = strlen (s2); for (I = 1; I <len1; I ++) dp [I] [0] = 0; for (j = 1; j <len2; j ++) dp [0] [j] = 0; for (I = 1; I <= len1; I ++) for (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 ;}