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

#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. Python入门3 —— 基本数据类型

    一:为何变量值(记录的数据)要有类型呢? 1.既然可以记录事物的状态,为什么要分类型呢? 变量值是来记录事物状态的, 而事物的状态是多种多样的, 所以对应着就要应该用不同类型的值去记录这些状态. 二: ...

  2. JS中使用lambda筛选list

    LevelEnum.filter(x=>x.Category=="水利工程")

  3. mongo gridfs 学习

    一.mongo是啥东西? MongoDB 是由C++语言编写的,基于分布式文件存储的开源数据库系统.在高负载的情况下,添加更多的节点,可以保证服务器性能. 二.gridfs是啥东西? 1.MongoD ...

  4. YARN High Availablity

    1. RM Failover ResourceManager HA 由一个Active/Standby 架构实现:在任何时间点,仅有一个RM是Active,其他一个(或多个)RM节点处于Standby ...

  5. 程序设计实验:一个Python游戏,体验软件开发。

    小组在GitHub上找了一个Pygame实现的超级马里奥游戏.所以我的学习过程大致如下: 1.快速学习Python基础语法. 2.学习pygame并着手理解这个项目. 3.完成作业以及各种文档报告. ...

  6. Centos610-oracle 备份和还原

    前言 本文是为基于Centos6.*(linux)系列的Oracle备份和还原的操作记录,其中根据expdp和impdp不同参数可实现不同场景下的导出导入,为不同OS下面的Oracle迁移打下基础. ...

  7. [python]Python 中 if not 用法

    在python 判断语句中 None, False, 空字符串"", 0, 空列表[], 空字典{}, 空元组()都相当于 False not None == not False ...

  8. PyQt5遇到的一个坑 "ImportError: unable to find Qt5Core.dll on PATH" 及解决办法

    最近再实现一个功能,主要是将自动化测试界面化 环境组合为:Windows 64bit + PyCharm + Python + PyQt5 + Pyinstaller + Inno Setup PS ...

  9. 【SIKI学院】愤怒的小鸟创建过程-2

    第二讲:Spring joint组建介绍 点重小鸟右侧add component输入spring joint,选择spring joint 2D(弹簧关节).给右侧树枝加刚体选择physics 2D- ...

  10. FreeRTOS学习笔记4:时间管理

    绝对时间:abs Time相对时间:百分比% time IDLE是空闲任务. RUN_Time_State:port...()初始化一个外设提供时基单元 //具体初始化要自己操作这个定时器的分辨率高于 ...