区间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 ;
}

最新文章

  1. Error:Execution failed for task &#39;:app:transformClassesWithDexForDebug&#39;.
  2. RaphaelJS实践--猫和老鼠矢量图展示
  3. ECSHOP 用户中心 我的订单前台显视订单每张商品图片及收货人
  4. LightOJ1417 Forwarding Emails(强连通分量+缩点+记忆化搜索)
  5. sp转dp dp转px
  6. win7 通过命令行压缩文件
  7. Photoshop:不起眼的背景橡皮擦
  8. MFC中获取指针的方法
  9. Jquery Ashx 存在缓存问题
  10. Labeling Balls
  11. Linux的时钟管理
  12. js清空页面控件值
  13. 屏幕录制H.264视频,AAC音频,MP4复,LibRTMP现场活动
  14. 2017-2018-2 20155314《网络对抗技术》Exp3 免杀原理与实践
  15. c日志宏
  16. Android在代码中获取meta标签内容
  17. collections系列之Counter
  18. pyquery学习笔记
  19. python 简单的猜数字游戏
  20. cad转shapefile文件

热门文章

  1. notepad++编辑器写python需注意使用utf-8编码
  2. 详解Python装饰器由浅入深
  3. C#窗体学生成绩管理系统
  4. 【贪心】HDU 最少拦截系统
  5. hdu 1563简单异或Find your present!
  6. Attribute &quot;not-null&quot; must be declared for element type &quot;property&quot;解决办法
  7. 洛谷P3406 海底高铁
  8. 【HDOJ6330】Visual Cube(模拟)
  9. HDU3549 最大流 裸题
  10. [Bzoj1022][SHOI2008]小约翰的游戏John(博弈论)