本文共 958 字,大约阅读时间需要 3 分钟。
1 #include 2 #include 3 #include 4 #include 5 #include 6 #include 7 #include 8 #include 9 #include 10 #include 11 #include 12 #include 13 #include 14 #include 15 #include 16 #include 17 #define INF 1e718 #define MAXN 10001019 #define maxn 100001020 #define Mod 100000721 #define N 101022 using namespace std;23 typedef long long LL;24 25 int T;26 string a, b;27 int dp[N][N];28 29 void run()30 {31 memset(dp, 0, sizeof(dp));32 cin >> a >> b;33 for (int i = 0; i < a.length(); ++i)34 for (int j = 0; j < b.length(); ++j)35 if (a[i] == b[j])36 dp[i + 1][j + 1] = dp[i][j] + 1;37 else38 dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);39 cout << dp[a.length()][b.length()] << endl;40 }41 42 int main()43 {44 cin >> T;45 while (T--)46 run();47 //system("pause");48 return 0;49 }
裸题
转载于:https://www.cnblogs.com/usedrosee/p/4356885.html