Lightoj 1025 - The Specials Menu
2024-10-20 03:33:41
区间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 ;
}
最新文章
- Error:Execution failed for task &#39;:app:transformClassesWithDexForDebug&#39;.
- RaphaelJS实践--猫和老鼠矢量图展示
- ECSHOP 用户中心 我的订单前台显视订单每张商品图片及收货人
- LightOJ1417 Forwarding Emails(强连通分量+缩点+记忆化搜索)
- sp转dp dp转px
- win7 通过命令行压缩文件
- Photoshop:不起眼的背景橡皮擦
- MFC中获取指针的方法
- Jquery Ashx 存在缓存问题
- Labeling Balls
- Linux的时钟管理
- js清空页面控件值
- 屏幕录制H.264视频,AAC音频,MP4复,LibRTMP现场活动
- 2017-2018-2 20155314《网络对抗技术》Exp3 免杀原理与实践
- c日志宏
- Android在代码中获取meta标签内容
- collections系列之Counter
- pyquery学习笔记
- python 简单的猜数字游戏
- cad转shapefile文件
热门文章
- notepad++编辑器写python需注意使用utf-8编码
- 详解Python装饰器由浅入深
- C#窗体学生成绩管理系统
- 【贪心】HDU 最少拦截系统
- hdu 1563简单异或Find your present!
- Attribute ";not-null"; must be declared for element type ";property";解决办法
- 洛谷P3406 海底高铁
- 【HDOJ6330】Visual Cube(模拟)
- HDU3549 最大流 裸题
- [Bzoj1022][SHOI2008]小约翰的游戏John(博弈论)