#include <stdio.h> #include<string.h> int max(int a, int b){ if(a > b) return a; return b; } int main() { int dp[101][101],a ,b; char s1[101], s2[101]; while (scanf("%s %s", s1, s2) != EOF) { // 注意 while 处理多个 case // 64 位输出请用 printf("%lld") to a = strlen(s1); b = strlen(s2); for (int i = 0; i<=a; i++) dp[i][0]=0; for (int i =0; i<=b; i++) dp[0][i]=0; for (int i=1; i<=a; i++) for(int j=1; j<=b;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[a][b]); } return 0; }