标签:bit main str char its == long for class
模板
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int MAXN=1e3+10;
char a[MAXN],b[MAXN];
int dp[MAXN][MAXN];
int main() {
scanf("%s%s",a+1,b+1);
int l1=strlen(a+1),l2=strlen(b+1);
for (int i=1;i<=l1;i++) dp[i][0]=i;
for (int i=1;i<=l2;i++) dp[0][i]=i;
for (int i=1;i<=l1;i++) {
for (int j=1;j<=l2;j++) {
int e=0;
if (a[i]==b[j]) e=0;
else e=1;
dp[i][j]=min(dp[i-1][j]+1,min(dp[i][j-1]+1,dp[i-1][j-1]+e));
}
}
printf("%d\n",dp[l1][l2]);
return 0;
}
标签:bit main str char its == long for class
原文地址:https://www.cnblogs.com/xyqxyq/p/12633093.html