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

#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. Custom LED Keychain, Small And Surefire Gifts

    The    LED Keychain    makes it easy for people to carry their keys with them and carry them with th ...

  2. HTML5学习(5)实体字符

    HTML   Entity 实体字符通常用于在页面中显示一些特殊符号. 书写方式: 1. &单词; 2. &#数字; 常用实体字符: <  < litter than &g ...

  3. HTML5学习(1)简介

    HTML5是HTML最新的修订版本,2014年10月由万维网联盟(W3C)完成标准制定. HTML5的设计目的是为了在移动设备上支持多媒体. HTML5 简单易学. 什么是 HTML5? HTML5 ...

  4. 前端分页神器,jquery grid的使用(前后端联调),让分页变得更简单。

    jquery grid 是一款非常好用的前端分页插件,下面来讲讲怎么使用. 首先需要引入jquery grid 的CSS和JS (我们使用的是bootstrap的样式) 下面我们通过一个例子来讲解,需 ...

  5. P1216 [IOI1994]数字三角形

    史上最水的 dp 题,没有之一(By rxz) 确实很简单,就算是我这个 dp 萌新也一眼看出来了转移方程 首先考虑状态,设 \(f_{i,j}\) 表示选择第 \(i\) 层第 \(j\) 个数时获 ...

  6. PHP高并发和大流量怎么解决?

    PHP高并发和大流量的解决方案 一 高并发的概念 在互联网时代,并发,高并发通常是指并发访问.也就是在某个时间点,有多少个访问同时到来. 二 高并发架构相关概念 1.QPS (每秒查询率) : 每秒钟 ...

  7. centos7安装Nginx 配置及反向代理

    Nginx是俄罗斯人编写的十分轻量级的HTTP服务器,Nginx,它的发音为“engine X”,是一个高性能的HTTP和反向代理服务器,同时也是一个IMAP/POP3/SMTP 代理服务器.Ngin ...

  8. 查询数据操作:limit

    1.作用: 在查看数据时用于限制获得的记录数量,一般放在最后. 2.语法: limit offset,row_count; 解析: offset:偏移量,索引值默认从0开始,可以省略 row_coun ...

  9. winform datagridview 同步滚动

    //首先添加 Scroll事件//同步滚动 private void dgYY_Scroll(object sender, ScrollEventArgs e) { ) { dgFee.FirstDi ...

  10. idea选中文件时左侧菜单自动定位到文件所在位置

    一:设置成自动定位,如图: 二:点击项目工程目录上的阻击按钮,自动定位