[codevs1520]回文字符串(dp)
来源:互联网 发布:程序员推荐用什么键盘 编辑:程序博客网 时间:2024/05/18 12:36
题目:
我是超链接
题解:
一上来的想法就是把这个字符串倒过来
按照我求的过程来说就是一个最长公共子序列(我也不知道是不是子串反正就是不连续的那个)
找到ta们能匹配上最长的序列,别的只能靠补了呗╮(╯▽╰)╭
用总长度减去就ok了
后方吐槽:没想到codevs也不兹瓷gets…….
代码:
#include <cstdio>#include <iostream>#include <cstring>using namespace std;char st[1005],st1[1005];int f[1005][1005];int main(){ int i,j; scanf("%s",st); int l=strlen(st); for (i=0;i<l;i++) st1[l-i]=st[i]; f[0][0]=1; for (i=1;i<=l;i++) for (j=1;j<=l;j++) if (st[i-1]==st1[j-1]) f[i][j]=f[i-1][j-1]+1; else f[i][j]=max(f[i-1][j],f[i][j-1]); printf("%d",l-f[l][l]);}
阅读全文
1 0
- [codevs1520]回文字符串(dp)
- [CODEVS1520]回文字符串(dp)
- codevs1520 回文字符串
- NYOJ - 回文字符串(DP)
- DP-回文字符串匹配
- uva10739(DP 回文字符串)
- 【DP入门】回文字符串
- DP 回文字符串 南洋理工
- nyoj 37 回文字符串 【DP】
- nyoj--37 回文字符串(dp)
- DP问题 制造回文字符串
- poj 3280 Cheapest Palindrome(回文字符串dp)
- 编程之美回文字符串,DP
- nyoj 37 回文字符串 【lcs&&dp】
- nyoj 37题 回文字符串 (dp)
- 51nod 1092 回文字符串 dp问题
- POJ1159回文字符串(DP+滚动数组)
- code vs 1520 回文字符串 (dp)
- 数据结构实验之链表八:Farey序列
- 只安装XCode’s Command line tools不安装XCode
- webbench对php和go语言的简单性能测试(含php7)
- ViewPager
- 高通G-sensor-2
- [codevs1520]回文字符串(dp)
- POJ 3261 后缀数组+二分
- css屏幕尺寸适应
- django-rest-framework安装
- Pulltorefresh上拉加载下拉刷新
- 高通G-sensor-3
- LeetCode 561. Array Partition I
- C++面试题
- centos 7时间同步方法