POJ-3356-AGTC
来源:互联网 发布:杭州软件外包情况 编辑:程序博客网 时间:2024/05/22 15:37
这个题题意求最少的增删改插操作,使得第一个字符串变成第二个字符串
思路:求最少编辑距离,转移方程式见代码中~
代码:
#include<cstdio>#include<cstring>#include<iostream>using namespace std;const int maxn=1010;char stra[maxn],strb[maxn];int lena,lenb,dp[maxn][maxn];int main(){ while(scanf("%d%s",&lena,&stra)!=EOF) { memset(dp,0,sizeof(dp)); scanf("%d%s",&lenb,&strb); int ans=0; for(int i=0;i<=lena;i++) dp[i][0]=i; for(int i=0;i<=lenb;i++) dp[0][i]=i; for(int i=1;i<=lena;i++) for(int j=1;j<=lenb;j++) { if(stra[i-1]==strb[j-1]) dp[i][j]=min(min(dp[i-1][j-1],dp[i-1][j]+1),dp[i-1][j-1]+1); else dp[i][j]=min(min(dp[i-1][j-1]+1,dp[i][j-1]+1),dp[i][j-1]+1); } printf("%d\n",dp[lena][lenb]); } return 0;}
- poj 3356 AGTC
- poj 3356 AGTC
- poj 3356 AGTC
- POJ-3356-AGTC
- poj 3356 AGTC
- POJ-3356-AGTC
- POJ 3356 AGTC
- POJ 3356 AGTC.
- POJ-3356-AGTC
- 【POJ 3356】AGTC
- (简单dp) poj 3356 AGTC
- poj 3356 AGTC 【编辑距离】
- poj 3356 AGTC 简单dp
- POJ-3356 AGTC(编辑距离)
- POJ 3356 AGTC(DP)
- POJ-3356(编辑距离)(AGTC)
- poj 3356 AGTC(lcs 变形题)
- [算法] poj 3356 字符串的距离 AGTC
- c++ viod 函数
- cocos2d-x高仿捕鱼达人实例分析(三)
- jquery ajax中使用jsonp的限制
- ARM中断处理过程
- [转载] 关于扬声器
- POJ-3356-AGTC
- WRK-NtOpenProcess 的流程草图~
- POJ-1887-Testing the CATCHER
- 第十五章Sqoop(2)
- jQuery学习总结
- 第15章Sqoop(3)
- json数据持久到MySQL
- 绑定本地Service并与之通信
- 高效率编辑器 VIM-操作篇,非常适合 VIM 新手