Ans

X-wangyiquan 2022-08-10 15:46:21 12 返回题目

#include<bits/stdc++.h>
using namespace std;
int f[201][201];
string s,t;
int n,m;
int main(){
    cin>>s>>t;
    n=s.size();
    m=t.size();
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            if(s[i-1]==t[j-1])  f[i][j]=f[i-1][j-1]+1;
            else f[i][j]=max(f[i-1][j],f[i][j-1]);
    
    cout<<f[n][m];
    return 0;
}
{{ vote && vote.total.up }}