#include <bits/stdc++.h> using namespace std; int main() { string s1, s2; cin >> s1 >> s2; if (s1 == "" || s2 == "") { cout << 0 << endl; return 0; } int m = s1.length(); int n = s2.length(); //开始dp int dp[m + 1][n + 1]; //初始化dp for (int i = 0; i <= m; i++) for (int j = 0; j <= n ; j++) dp[i][j] = 0; for (int i = 1; i <= m; i++) { for (int j = 1; j <= n; j++) { if (s1[i-1] == s2[j-1]) { dp[i][j] = dp[i - 1][j - 1] + 1; } else { dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]); } } } cout << dp[m][n]; } // 64 位输出请用 printf("%lld")