最小编辑代价
来源:互联网 发布:手机淘宝怎么放优惠券 编辑:程序博客网 时间:2024/06/12 23:07
#include "iostream" #include "string" #include <algorithm>#include <vector> using namespace std;int findMinCost(string A, int n, string B, int m, int c0, int c1, int c2) { int dp[256][256]; memset(dp, 0, sizeof(int) * 256 * 256); for (int i = 1; i <= n;i++) dp[i][0] = dp[i - 1][0] + c1; for (int j = 1; j <= m; j++) dp[0][j] = dp[0][j - 1] + c0; for (int i = 1; i <= n; i++) { for (int j = 1; j <= m; j++) { if (A[i - 1] == B[j - 1]) dp[i][j] = dp[i - 1][j - 1]; else dp[i][j] = min(dp[i - 1][j - 1] + c2, min(dp[i][j - 1] + c0, dp[i - 1][j] + c1)); } } return dp[n][m];}//测试int main(int argc, char const *argv[]){ string s1 = "abc", s2 = "adc"; cout << findMinCost(s1, 3, s2, 3, 5, 3, 100) << endl;}
0 0
- 最小编辑代价
- 最小编辑代价
- 最小编辑代价
- 最小编辑代价
- godfrey_88 最小编辑代价
- 最小编辑代价
- 最小编辑代价
- 最小编辑代价
- 【动态规划】最小编辑代价
- 最小编辑代价---动态规划
- 最小编辑代价 动态规划
- 最小编辑代价(动态规划)
- 最小编辑代价(动态规划)
- 最小编辑代价(动态规划)
- 递归与动态规划---最小编辑代价
- 动态规划系列问题-最小编辑代价
- 最小代价
- 最小代价;;;;
- CAS 引起的乱码问题解决
- POJ3414-Pots
- 【JZOJ 4678】钱仓
- [Java]Collection总结
- 基于Jmeter和Jenkins搭建性能测试框架
- 最小编辑代价
- poj 3009 Curling 2.0
- 数据结构实验之二叉树二:遍历二叉树
- hdu 5826 physics
- react native fect network request failed
- DIY智能插座(二) -- C51单片机编码
- RunLoop处理逻辑-网友整理版
- Android开源库集锦
- 走迷宫