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的方案数 ...
随机推荐
- [第一波模拟\day3\T3]{益智游戏}(game.cpp)
[问题描述] 小P和小R在玩一款益智游戏.游戏在一个正权有向图上进行. 小P控制的角色要从A点走最短路到B点,小R控制的角色要从C点走最短路到D点. 一个玩家每回合可以有两种选择,移动到一个相邻节点或 ...
- mybatis自动映射和手动映射
一对一查询 第一种方法: <!-- 查询所有订单信息 --> <select id="findOrdersList" resultType="cn.it ...
- hihoCoder#1105 题外话·堆
原题地址 有没有更优雅地堆模板啊,总感觉我写的有些啰嗦 代码: #include <iostream> using namespace std; #define MAX_NODE 1000 ...
- [POJ1984]Navigation Nightmare
[POJ1984]Navigation Nightmare 试题描述 Farmer John's pastoral neighborhood has N farms (2 <= N <= ...
- codeforces #299 div 2
(总算是5题都做完了- -) 暂时做了4题,先放一下有时间做最后一题(当然如果我真的能做出的话...)(看了大神的代码总算是理解了E题,做完发现也没那么难,果然想出一个思路的过程对于我这种弱渣来说还是 ...
- 【概率dp】C. Race to 1 Again
https://www.bnuoj.com/v3/contest_show.php?cid=9146#problem/C [题意] 给定一个数D,每次随机选取这个数的一个因子x得到新的数D=D/x,知 ...
- BZOJ1739: [Usaco2005 mar]Space Elevator 太空电梯
n<=400个东西,每个东西有高度<=100,这种东西在堆放过程中不得超过的最大高度<=40000,以及每个东西的个数<=10,求最高能堆多高. 算了下背包复杂度不太对然后开了 ...
- msp430项目编程07
msp430中项目---简单计算器 1.扫描键盘工作原理 2.电路原理说明 3.代码(显示部分) 4.代码(功能实现) 5.项目总结 msp430项目编程 msp430入门学习
- HDU 5695 Gym Class
拓扑排序. #include<cstdio> #include <iostream> #include<cstring> #include<cmath> ...
- hdu6110(线段树+lca)
题目 http://acm.hdu.edu.cn/showproblem.php?pid=6110 分析 注意到,若干条路径的交一定也是条路径 我们可以维护一个线段树,seg[l..r]存着第l条~第 ...