#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <string>
#include <algorithm>
#include <stdlib.h>
using namespace std;
string a,b;
int common[205][205];
void init();
void dp();
int main(){
init();
dp();
cout << common[a.size()][b.size()]<<endl;
return 0;
}
void dp(){
for(int i=1;i<=a.size();i++){
for(int j = 1;j<=b.size();j++){
if(a[i-1] == b[j-1]){
common[i][j] = common[i-1][j-1]+1;
}else{
common[i][j] = max(common[i-1][j],common[i][j-1]);
}
}
}
}
void init(){
cin >> a >> b;
for(int i=0;i<205;i++){
for(int j=0;j<205;j++){
common[i][j] = 0;
}
}
}
来源:https://blog.csdn.net/qq_36323559/article/details/102761233