千和


私信TA

用户名:wyt23333

访问量:983

签 名:

就算想法幼稚短浅也不能忘记前进

等  级
排  名 10153
经  验 1048
参赛次数 0
文章发表 6
年  龄 0
在职情况 学生
学  校 东华理工大学
专  业

  自我简介:

解题思路:

注意事项:

参考代码:

#include<bits/stdc++.h>
using namespace std;

string s1;
string s2;
int L1,L2;

int dp[202][202];

int DP_(){
    //fill(dp[0],dp[0]+202*202,1);


for(int i=1;i<=L1;i++){
    for(int j=1;j<=L2;j++){
        if(s1[i-1]==s2[j-1]){
            dp[i][j]=dp[i-1][j-1];
            continue;
        }
        dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
    }
}
    /*for(int i=0;i<=L1;i++){
        for(int j=0;j<=L2;j++){
            cout<<dp[i][j]<<" ";
        }
        cout<<endl;
    }*/
    return dp[L1][L2];
}

main(){
    cin>>s1>>s2;
    L1=s1.length();
    L2=s2.length();
    int ans=DP_();
    cout<<ans;
}


 

0.0分

0 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区