51nod 1092 回文字符串 【巧用 dp】
来源:互联网 发布:获取对方通话记录软件 编辑:程序博客网 时间:2024/06/05 23:49
用原串和倒置串进行匹配 统计不同的单词的个数 该个数即为 需要添加的 也为 需要删除的
#include<bits/stdc++.h>using namespace std;const int ma=1e3+10;int dp[ma][ma];int main(){ ios::sync_with_stdio(false); string a,b; cin>>a; b=a; reverse(b.begin(),b.end()); int n=b.size(); for(int i=0;i<n;i++) for(int j=0;j<n;j++) { if(a[i]==b[j]) dp[i+1][j+1]=dp[i][j]+1; else dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]); } cout<<n-dp[n][n]<<endl; return 0;}
阅读全文
0 0
- 51nod 1092 回文字符串 【巧用 dp】
- 51nod 1092 回文字符串 dp问题
- 51nod 1092 回文字符串(区间dp)
- 51 NOD 1092 回文字符串(DP)
- 51Nod 1092 回文字符串(LCS跟dp)
- 51nod 1092 回文字符串 LCS 或 区间dp
- 【51nod】1092 回文字符串
- 1092 回文字符串(51nod)
- 51 nod 1092 回文字符串
- 51nod 1092 回文字符串
- 51nod 1092 回文字符串
- 51nod-【1092 回文字符串】
- 51nod 1092 回文字符串
- 51Nod 1092 回文字符串
- 51nod 1092 回文字符串
- 51Nod 1092 回文字符串
- 51nod 1092 回文字符串
- 51nod 1092 回文字符串
- python通过定制路径的方式解析接口返回数据
- 5.轨迹抽象,关键点序列生成
- 【bzoj4403】【序列统计】不降转升+组合数添项合并
- EL表达式截取字符串
- leetcode006-Search for a Range
- 51nod 1092 回文字符串 【巧用 dp】
- 初入Linux
- AngularJs示例简单增删改查
- MATLAB实现双目校准
- 给你90天,成为不一样的自己
- java中的方法(函数)的定义
- HBase安装与配置
- 3Sum
- linux通信机制signal()函数详解