Lightoj 1025 - The Specials Menu
区间dp
/* ***********************************************
Author :guanjun
Created Time :2016/6/30 23:24:27
File Name :1025.cpp
************************************************ */
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <stdlib.h>
#include <iomanip>
#include <list>
#include <deque>
#include <stack>
#define ull unsigned long long
#define ll long long
#define mod 90001
#define INF 0x3f3f3f3f
#define maxn 10010
#define cle(a) memset(a,0,sizeof(a))
const ull inf = 1LL << ;
const double eps=1e-;
using namespace std;
priority_queue<int,vector<int>,greater<int> >pq;
struct Node{
int x,y;
};
struct cmp{
bool operator()(Node a,Node b){
if(a.x==b.x) return a.y> b.y;
return a.x>b.x;
}
}; bool cmp(int a,int b){
return a>b;
}
ll dp[][];
char s[];
int main()
{
#ifndef ONLINE_JUDGE
freopen("in.txt","r",stdin);
#endif
//freopen("out.txt","w",stdout);
int T;
cin>>T;
for(int t=;t<=T;t++){
scanf("%s",s+);
int n=strlen(s+);
cle(dp);
for(int len=;len<=n;len++){
for(int i=;i+len-<=n;i++){
int j=i+len-;
dp[i][j]+=dp[i+][j]+dp[i][j-]-dp[i+][j-];
if(s[i]==s[j])dp[i][j]+=dp[i+][j-]+;
}
}
printf("Case %d: %lld\n",t,dp[][n]);
}
return ;
}
Lightoj 1025 - The Specials Menu的更多相关文章
- Lightoj 1025 - The Specials Menu (区间DP)
题目链接: Lightoj 1025 - The Specials Menu 题目描述: 给出一个字符串,可以任意删除位置的字符,也可以删除任意多个.问能组成多少个回文串? 解题思路: 自从开始学dp ...
- 1025 - The Specials Menu
1025 - The Specials Menu PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...
- Light OJ 1025 - The Specials Menu(动态规划-区间dp)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1025 题目大意:一串字符, 通过删除其中一些字符, 能够使这串字符变成回文串. ...
- Light OJ 1025 - The Specials Menu(区间DP)
题目大意: 给你一个字符串,问有多少种方法删除字符,使得剩下的字符是回文串. 有几个规定: 1.空串不是回文串 2.剩下的字符位置不同也被视为不同的回文串.如:AA有三种回文串 A, A, A ...
- The Specials Menu LightOJ - 1025
The Specials Menu LightOJ - 1025 题意:在给定的字符串中删去一些字符,使其成为回文串(不能全部都删).求方案数. 方法:常规的区间dp.ans[i][j]表示在i到j的 ...
- 【lightoj-1025】The Specials Menu(区间DP)
题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1025 [题目大意] 求一个字符串删去任意字符可以构成多少个不同的回文串 [分析 ...
- LightOJ1025 The Specials Menu(区间DP)
给一个字符串,问有几种删字符的方式使删后的非空字符串是个回文串. 当然区间DP:dp[i][j]表示子串stri...strj的方案数 感觉不好转移,可能重复算了.我手算了"AAA" ...
- lightoj 1025 区间dp
#include<bits/stdc++.h> using namespace std; typedef long long ll; char a[70]; ll dp[70][70]; ...
- lightoj 1025【区间DP】
题意: 给出一个word,求有多少种方法你从这个word清除一些字符而达到一个回文串. 思路: 区间问题,还是区间DP: 我判断小的区间有多少,然后往外扩大一点. dp[i,j]就代表从i到j的方案数 ...
随机推荐
- 今年把js总结了一下,ppt格式的
本来想梳理成html,但是时间有限. 希望能够有所帮助. http://pan.baidu.com/s/1ntGAfED http://files.cnblogs.com/danghuijian/js ...
- navicat不同数据库数据传输
复制fo的t_fo_account表结构和数据到base库 结果
- 大数据学习——HDFS的shell
-help 功能:输出这个命令参数手册 -ls 功能:显示目录信息 示例: hadoop fs -ls hdfs://hadoop-server01:9000/ 备注:这些参数中,所有的hdfs路径都 ...
- java数据结构简单点
java常用的数据结构一 集合框架主要就是Collection和Map: 1.Collection包含了List和Set两大分支. (1)List是一个有序的集合,每一个元素都有它的索引.第一个元素的 ...
- Oracle中有关日期的语法
Oracle中有关日期的语法 Oracle提供了丰富的日期函数.利用日期函数可以灵活的对日期进行运算. to_date()函数——将字符串转换为日期型 to_date()函数用于将字符串转换为日期.被 ...
- python基础知识--条件判断和循环
一.输入输出 python怎么来接收用户输入呢,使用input函数,python2中使用raw_input,接收的是一个字符串,输出呢,第一个程序已经写的使用print,代码入下: 1 name=in ...
- [NOIP1998] 提高组 洛谷P1012 拼数
题目描述 设有n个正整数(n≤20),将它们联接成一排,组成一个最大的多位整数. 例如:n=3时,3个整数13,312,343联接成的最大整数为:34331213 又如:n=4时,4个整数7,13,4 ...
- 视图中使用foreach报错问题
问题情境:thinkphp3.2版本,使用四层<foreach></foreach>循环变量时,报错以下错误: syntax error, unexpected 'endfor ...
- python之-- socket 基础篇
socket 网络模块 注意事项:在python3中,所有数据的传输必须用bytes类型(bytes只支持ascii码)所以在发送数据的时候要么在发送的字符串前面加 'b',要么使用encode('u ...
- (二)Commonjs规范与模块化
在之前的学习中我们使用require()来引入我们需要的包,这其实就是模块化,各模块相互独立,可以通过某种方式引入别的模块.而这些引入方式都是遵循一定的规范的,这就是CommonJS规范. 一.Com ...