- 最短编辑距离
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 1001;
int f[N][N];
int n, m;
char w1[N], w2[N];
int main()
{cin >> n >> w1 + 1;cin >> m >> w2 + 1;for (int i = 0; i <= m; i++)f[0][i] = i;for (int i = 0; i <= n; i++)f[i][0] = i;for (int i = 1; i <= n; i++)for (int j = 1; j <= m; j++){f[i][j] = min(f[i - 1][j] + 1, f[i][j - 1] + 1);if (w1[i] == w2[j])f[i][j] = min(f[i][j], f[i - 1][j - 1]);elsef[i][j] = min(f[i][j], f[i - 1][j - 1] + 1);}cout << f[n][m] << endl;return 0;
}