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

#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. 1060 Are They Equal (25分)

    1060 Are They Equal (25分) 题目 思路 定义结构体 struct fraction{ string f; int index; } 把输入的两个数先都转换为科学计数法,统一标准 ...

  2. Java 数据库树形查询生成菜单结构

    Java 数据库树形查询 JAVA从数据库读取菜单,递归生成菜单树. 定义菜单类 public class Menu { // 菜单id private String id; // 菜单名称 priv ...

  3. 【Python】 平方根

    平方根,又叫二次方根,表示为[√ ̄],如:数学语言为:√ ̄16=4.语言描述为:根号下16=4. 以下实例为通过用户输入一个数字,并计算这个数字的平方根: num = float(input('请输入 ...

  4. 每天进步一点点------Xilinx DCM

    时钟---锁相环 1.       Xilinx DCM 数字时钟管理模块(Digital Clock Manager,DCM)是基于Xilinx的其他系列器件所采用的数字延迟锁相环(DLL,Dela ...

  5. Oracle常用函数记录

    Oracle函数 --schema:hcf --不带任何参数 http://www.cnblogs.com/wuyisky/archive/2010/05/11/oracle_function.htm ...

  6. 【转载】C++面试题(1-50)

    转自http://www.jobui.com/mianshiti/it/cpp/5017/ 1.    面向对象的程序设计思想是什么? 答:把数据结构和对数据结构进行操作的方法封装形成一个个的对象. ...

  7. c#修改项目名称

    1.修改解决方案名称 右键,重命名 2.修改项目名称 右键,重命名 3.修改程序集名称和默认命名空间 项目,属性 4.替换解决方案中的名称 编辑,替换,替换范围默认整个解决方案 5.用记事本打开.sl ...

  8. MongoDB_05_更新和删除

    文档的更新和删除 更新文档的方法: db.collection.update(query,update,options) //或 db.collection.update( <query> ...

  9. 10day rpm简单用法qa ql qf "`"用法

    查看软件是否安装: [root@oldboyedu ~]# rpm -qa sl -q表示查询 -a表示所有 sl-5.02-1.el7.x86_64 查看软件包中有哪些信息 [root@oldboy ...

  10. Java - JVM - jinfo

    1. 概述 jinfo java 运行时的配置工具 查看 设置 2. 环境 idea 2018.2 java jdk8 3. 准备 写个 死循环 概述 需要查看 jvm 的信息, 必须有个运行中的 j ...