区间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的更多相关文章

  1. Lightoj 1025 - The Specials Menu (区间DP)

    题目链接: Lightoj 1025 - The Specials Menu 题目描述: 给出一个字符串,可以任意删除位置的字符,也可以删除任意多个.问能组成多少个回文串? 解题思路: 自从开始学dp ...

  2. 1025 - The Specials Menu

    1025 - The Specials Menu    PDF (English) Statistics Forum Time Limit: 2 second(s) Memory Limit: 32 ...

  3. Light OJ 1025 - The Specials Menu(动态规划-区间dp)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1025 题目大意:一串字符, 通过删除其中一些字符, 能够使这串字符变成回文串. ...

  4. Light OJ 1025 - The Specials Menu(区间DP)

    题目大意:     给你一个字符串,问有多少种方法删除字符,使得剩下的字符是回文串. 有几个规定: 1.空串不是回文串 2.剩下的字符位置不同也被视为不同的回文串.如:AA有三种回文串 A, A, A ...

  5. The Specials Menu LightOJ - 1025

    The Specials Menu LightOJ - 1025 题意:在给定的字符串中删去一些字符,使其成为回文串(不能全部都删).求方案数. 方法:常规的区间dp.ans[i][j]表示在i到j的 ...

  6. 【lightoj-1025】The Specials Menu(区间DP)

    题目链接:http://www.lightoj.com/volume_showproblem.php?problem=1025 [题目大意] 求一个字符串删去任意字符可以构成多少个不同的回文串 [分析 ...

  7. LightOJ1025 The Specials Menu(区间DP)

    给一个字符串,问有几种删字符的方式使删后的非空字符串是个回文串. 当然区间DP:dp[i][j]表示子串stri...strj的方案数 感觉不好转移,可能重复算了.我手算了"AAA" ...

  8. lightoj 1025 区间dp

    #include<bits/stdc++.h> using namespace std; typedef long long ll; char a[70]; ll dp[70][70]; ...

  9. lightoj 1025【区间DP】

    题意: 给出一个word,求有多少种方法你从这个word清除一些字符而达到一个回文串. 思路: 区间问题,还是区间DP: 我判断小的区间有多少,然后往外扩大一点. dp[i,j]就代表从i到j的方案数 ...

随机推荐

  1. 查看linux ubuntu版本

    ubuntu版本: lsb_release -a  linux版本: uname -a proc目录下记录的当前系统运行的各种数据,version记录的版本信息直接可以通过cat查看到. 使用命令:c ...

  2. xtu字符串 B. Power Strings

    B. Power Strings Time Limit: 3000ms Memory Limit: 65536KB 64-bit integer IO format: %lld      Java c ...

  3. HDU1280前m大的数creat at 9:51,3.13,2016

    前m大的数 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Subm ...

  4. CodeForces 444C 节点更新求变化值的和

    http://vjudge.net/problem/viewProblem.action?id=51622 题目大意: 给定一列n个数字,最初赋予值1到n 两个操作:1.将区间[l,r]内的数改为x, ...

  5. SeLion数据驱动中遇到的问题,以及解决方案

    问题描述: 使用selion框架数据驱动时,总是test ignored. 解决方案: 把这个dataprovider方法拿出来做单元测试.有详细报错. 问题1:使用wps保存,poi包只能解析xls ...

  6. 全局Session-GlobalSession

    import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpSession; import org.spri ...

  7. CodeForces 595A Vitaly and Night

    水题. #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> u ...

  8. Spring4 基本使用

    前言 虽然现在基本上是 springboot 的天下了,但是传统的 spring4 在广大的软件企业中仍然占据很大比例.一上手能用,但是要让我从无到有搭一个spring4的开发环境出来,可能会磕磕碰碰 ...

  9. 2018 11.1 PION 模拟赛

    期望:250  100+100+50 实际:210   80+100+30 期望:100   实际:80 最后:两个点T了.可能是求逆元的方法太慢了,也可能是闲的又加了一个快速乘的原因. #inclu ...

  10. Python导入模块的几种姿势

    中文翻译:http://codingpy.com/article/python-import-101/ 英文原文:http://www.blog.pythonlibrary.org/2016/03/0 ...