标签:tps targe view ++ pre src logs display style
1 #include <bits/stdc++.h> 2 using namespace std; 3 const int maxn = 1010; 4 5 char s[maxn], p[maxn]; 6 int dp[maxn][maxn]; 7 8 int main(){ 9 scanf("%s %s", s, p); 10 int n = strlen(s); 11 int m = strlen(p); 12 for(int i = 0; i <= n; i++) dp[i][0] = i; 13 for(int i = 0; i <= m; i++) dp[0][i] = i; 14 for(int i = 1; i <= n; i++){ 15 for(int j = 1; j <= m; j++){ 16 dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + 1; 17 dp[i][j] = min(dp[i][j], dp[i-1][j-1] + (s[i-1] != p[j-1])); 18 } 19 } 20 printf("%d\n", dp[n][m]); 21 }
标签:tps targe view ++ pre src logs display style
原文地址:http://www.cnblogs.com/yijiull/p/7712498.html