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

#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. jdk8-》日期时间及其格式处理类特性

    一.JDK8之时间⽇期处理类 核⼼类: LocalDate:不包含具体时间的⽇期. LocalTime:不含⽇期的时间. LocalDateTime:包含了⽇期及时间. LocalDate 常⽤API ...

  2. Java-POJ1003-Hangover

    题目大意: 给出一个浮点数a,求出使得 不等式 1/2 + 1/3 + ... + 1/(n+1) ≥ a 成立的最小值 大水题,由于数据范围小,给出了确认上界5.20,满足二分答案 但是我懒啊,直接 ...

  3. [git] git合并冲突 本地已有项目上传 各种问题

    git... 讲道理 我现在能隐约感觉到他的强大控制能力了 但是依旧是不习惯.... 无论是什么操作 在我这里都会出问题,,,, 上传本地已有的项目到码云 首先需要现在码云创建一个仓库 然后用git工 ...

  4. php curl请求 header头携带参数

    $headers = array(    'api-key:'.$key,    'authorization:'.$authorization,      ); //初始化    $curl = c ...

  5. mongo shell远程连接使用数据库

    mongo mydb --username user1 --host --password --username 用户名 --host 连接ip --port 连接端口号 --password 密码 ...

  6. STL顺序容器用法自我总结

    顺序容器类型:vector.deque.list.forward_list.string.array. queue(单向队列)底层也是用deque(双端队列)实现的 a.swap(b); swap(a ...

  7. bugku 隐写2

    首先打开链接发现是一张图片 然后分析一下图片 发现这个图片实际是一个压缩包 然后更改一下后缀名 改成zip 然后解压之后会发现另一个压缩包和一张图片压缩包需要密码然后这个图片是一个提示 然后分析 (我 ...

  8. Navicat Premium破解

    1.正常下载安装 2.把PatchNavicat.exe文件放到Navicat安装目录下 3.以管理员身份启动PatchNavicat.exe 4.运行Navicat即可

  9. Mysql实现级联操作(级联更新、级联删除)(转)

    一.首先创建两张表stu,sc create table stu( sid int UNSIGNED primary key auto_increment, name varchar(20) not ...

  10. ftrace使用

    前段时间遇到个问题,有个后继音频数据处理线程调度不及时导致音频输出延迟,音视频不同步. 因此从系统上入手,采用ftrace进行debug,来看有哪些线程会去抢占音频数据处理线程. ftrace 提供了 ...