删除字符的镜像问题,状态转移方程一样~

#include<bits/stdc++.h>
using namespace std;
const int maxn=;
const int mod=1e9+;
string s;
long long dp[maxn][maxn];
int main () {
cin>>s;
fill (dp[],dp[]+maxn,);
int t=max(,(int)(s.length()-));
for (int i=;i<s.length();i++) {
for (int j=i;j<=s.length();j++) {
dp[i][j]=dp[i][j-]%mod+dp[i-][j-]%mod;
dp[i][j]%=mod;
for (int k=j-;j-k<=i;k--) {
if (s[k-]==s[j-]) {
dp[i][j]-=dp[i-(j-k)][k-];
break;
}
}
}
}
long long sum=;
for (int i=t;i<s.length();i++) {
sum+=dp[i][s.length()];
sum%=mod;
}
printf ("%lld",sum);
return ;
}

PAT T1025 Keep at Most 100 Characters的更多相关文章

  1. [LeetCode] Count The Repetitions 计数重复个数

    Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc&qu ...

  2. UVA 1401 Remember the Word

    字典树优化DP                                Remember the Word Time Limit: 3000MS   Memory Limit: Unknown ...

  3. Creating a SharePoint Sequential Workflow

    https://msdn.microsoft.com/en-us/library/office/hh824675(v=office.14).aspx Creating a SharePoint Seq ...

  4. UVALive - 3942 Remember the Word[Trie DP]

    UVALive - 3942 Remember the Word Neal is very curious about combinatorial problems, and now here com ...

  5. MySQL主从同步延迟

    早上接到open-falcon报警,一台mysql从库同步延迟2w多秒,mysql版本比较老,用的5.1.37. 连接从库查找原因: show processlist一下,查看哪些线程在跑. 看到Ti ...

  6. Leetcode: Count The Repetitions

    Define S = [s,n] as the string S which consists of n connected strings s. For example, ["abc&qu ...

  7. test 2016-12-6

    //$token = drupal_get_token('abc'); //dpm(drupal_valid_token($token,'abc')); //1 //从任何字符串生成一个密码形式的字符 ...

  8. coderforces 721b

    题目描述: B. Passwords time limit per test 2 seconds memory limit per test 256 megabytes input standard ...

  9. MOTION-MATCHING IN UBISOFT’S FOR HONOR翻译

    http://www.gameanim.com/2016/05/03/motion-matching-ubisofts-honor/ Introducing For Honor with a vide ...

随机推荐

  1. redis源码(八)redis-check-aof.c

    /* * Copyright (c) 2009-2012, Pieter Noordhuis <pcnoordhuis at gmail dot com> * Copyright (c) ...

  2. Adobe 系列下载链接

    (注意!:在下方链接前加上 "pan.baidu.com/s/" 才是正确网址,用"百度网盘"下载) Photoshop 专区(图像处理软件) Adobe Ph ...

  3. 【资源分享】Gmod动态方框透视脚本

    *----------------------------------------------[下载区]----------------------------------------------* ...

  4. ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked.

    ExpressionChangedAfterItHasBeenCheckedError: Expression has changed after it was checked. 解决方案: 异步更新 ...

  5. STA 开篇

    时序分析=动态时序分析+静态时序分析 动态时序分析简单讲就是gate-level simulation,仿真对象是netlist+sdf,通过SDF反标,得到gate跟net的delay,通过输入大量 ...

  6. Git-配置SSH公钥

    前言:Git是分布式的代码管理工具,远程的代码管理是基于SSH的,所以要使用远程的Git则需要SSH的配置. 以下操作都在git-bash命令行中进行. 查看所有配置项: git config --l ...

  7. Abp中打开错误信息输出

    Abp默认是不向客户端输出错误日志的,导致有些内部报错既不能中断,也没有信息输出.此时打开日志输出开关即可.在xxModule类中PreInitialize()方法里 Configuration.Mo ...

  8. leetcode 25. K 个一组翻转链表

    # coding:utf-8 __author__ = "sn" """ 25. K 个一组翻转链表 给你一个链表,每 k 个节点一组进行翻转,请你返 ...

  9. opencv编译静态库时选择MD模式无效的原因

    在Cmake-gui上看到的明明是MD运行库依赖,生成MS项目时却变成了MT运行库依赖. 原因在于编译静态库时内部做了自动替换.

  10. Mac电脑怎么远程桌面连接

    https://jingyan.baidu.com/article/e75aca85039448142fdac651.html https://blog.csdn.net/youshaoduo/art ...