Light OJ 1025 - The Specials Menu(区间DP)
题目大意:
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<queue>
#include<vector>
#include<map>
using namespace std;
typedef long long LL;
const int INF = 1e9+;
const int MAXN = ;
char str[MAXN];
LL dp[MAXN][MAXN];
LL DFS(int L,int R)
{
if(L > R) return ;
if(dp[L][R]) return dp[L][R];
if(L == R) return dp[L][R] = ; dp[L][R] = DFS(L+,R) + DFS(L,R-) - DFS(L+,R-);
if(str[L] == str[R])
dp[L][R] += DFS(L+, R-) + ;
return dp[L][R];
} int main()
{
int T, cas = ;
scanf("%d", &T);
while(T --)
{
memset(dp, , sizeof(dp));
scanf("%s", str);
int len = strlen(str);
printf("Case %d: %lld\n",cas ++, DFS(,len-));
} return ;
}
Light OJ 1025 - The Specials Menu(区间DP)的更多相关文章
- Lightoj 1025 - The Specials Menu (区间DP)
题目链接: Lightoj 1025 - The Specials Menu 题目描述: 给出一个字符串,可以任意删除位置的字符,也可以删除任意多个.问能组成多少个回文串? 解题思路: 自从开始学dp ...
- Light OJ 1025 - The Specials Menu(动态规划-区间dp)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1025 题目大意:一串字符, 通过删除其中一些字符, 能够使这串字符变成回文串. ...
- Light OJ 1031 - Easy Game(区间DP)
题目大意: 给你一个n,代表n个数字,现在有两个选手,选手A,B轮流有有一次机会,每个选手一次可以得到一个或者多个数字,从左侧或者右侧,但是不能同时从两边取数字,当所有的数字被取完,那么游戏结束.然后 ...
- Light oj 1044 - Palindrome Partitioning(区间dp)
题目链接:http://lightoj.com/volume_showproblem.php?problem=1044 dp[i][j]表示i到j直接的最小回文区间个数,直接看代码 #include ...
- 1025 - The Specials Menu
1025 - The Specials Menu PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...
- Lightoj 1025 - The Specials Menu
区间dp /* *********************************************** Author :guanjun Created Time :2016/6/30 23:2 ...
- light oj 1140 - How Many Zeroes? 数位DP
思路:dp[i][j]:表示第i位数,j表示是否有0. 代码如下: #include<iostream> #include<stdio.h> #include<algor ...
- Light OJ 1021 - Painful Bases(状态压缩DP)
题目大意: 给你一个base 进制的数字,把这个数字的每一位进行全排列,问有多少个数字是可以整除k的. 题目解析: #include<cstdio> #include<cstring ...
- Light OJ 1004 - Monkey Banana Problem(DP)
题目大意: 给你一菱形的数字阵,问从最上面走到最下面所能获得的最大值是多少? #include<cstdio> #include<cstring> #include<io ...
随机推荐
- PHP 开启报错机制
屏蔽PHP错误提示 方法一:在有可能出错的函数前加@,然后or die("") 如: @mysql_connect(...) or die("Database Conne ...
- Store update, insert, or delete statement affected an unexpected number of rows ({0}).
问题描述 Store update, insert, or delete statement affected an unexpected number of rows ({0}). Entities ...
- datagrid后台给每列添加js方法
protected void dgExhList_ItemDataBound(object sender, DataGridItemEventArgs e) { string param = &quo ...
- zabbix 基于JMX的Tomcat监控
zabbix 基于JMX的Tomcat监控 一.环境 ubuntu14.04 LTS Java 1.7.0 zabbix 2.4.5 二.安装配置 1.安装JavaGateway 在ubuntu14. ...
- eclipse(myEclipse) 配置maven项目
工作中在myeclipse中导入maven工程后,在pom.xml文件目录执行了mvn eclipse:eclipse 后,发现项目中缺少"Maven Dependencies"目 ...
- java中json转xml
参考:http://heipark.iteye.com/blog/1394844 需要json-lib-2.1-jdk15.jar和xom-1.2.5.jar,maven pom.xml如下: xml ...
- Missing iOS Distribution signing identity问题解决
问题描述 打包上传APPStore Xcode报以下错误:Missing iOS Distribution signing identity for XXXXXX 查看证书后发现,Develop证书 ...
- 解决UITableViewCell左侧分割线有空白的问题
ios7中,UITableViewCell左侧会有默认15像素的空白.设置setSeparatorInset:UIEdgeInsetsZero 能将空白去掉. ios8中,setSeparatorIn ...
- SGU 190.Dominoes(二分图匹配)
时间限制:0.25s 空间限制:4M 题意: 给定一个N*N的棋盘,一些格子被移除,在棋盘上放置一些1*2的骨牌,判定能否放满,并且输出任意方案. Solution: 首先考虑对棋盘的一个格子黑白染色 ...
- 【POJ3481】【splay】Double Queue
Description The new founded Balkan Investment Group Bank (BIG-Bank) opened a new office in Bucharest ...