UVA 11584 一 Partitioning by Palindromes
Time Limit:1000MS Memory Limit:0KB 64bit IO Format:%lld & %llu
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; char a[]; int C(int x,int y)
{
int flg=;
while(x<y)
{
if(a[x]!=a[y])
{
flg=;
break;
}
x++,y--;
}
return flg;
} int main()
{
int T;
int dp[];
scanf("%d",&T);
while(T--)
{
int n,i,j;
scanf("%s",a);
memset(dp,,sizeof(dp));
n=strlen(a);
dp[]=;
for(i=;i<n;i++)
{
dp[i]=dp[i-]+;
for(j=i-;j>;j--)
{
if(C(j,i))
{
dp[i]=min(dp[i],dp[j-]+);
}
}
if(C(,i))
dp[i]=;
}
/*for(i=0;i<n;i++)
printf("%d ",dp[i]);
printf("\n");*/
printf("%d\n",dp[n-]);
}
return ;
}
UVA 11584 一 Partitioning by Palindromes的更多相关文章
- 【Uva 11584】Partitioning by Palindromes
[Link]:https://cn.vjudge.net/contest/170078#problem/G [Description] 给你若干个只由小写字母组成的字符串; 问你,这个字符串,最少能由 ...
- UVA - 11584 Partitioning by Palindromes[序列DP]
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is t ...
- uva 11584 Partitioning by Palindromes 线性dp
// uva 11584 Partitioning by Palindromes 线性dp // // 题目意思是将一个字符串划分成尽量少的回文串 // // f[i]表示前i个字符能化成最少的回文串 ...
- 区间DP UVA 11584 Partitioning by Palindromes
题目传送门 /* 题意:给一个字符串,划分成尽量少的回文串 区间DP:状态转移方程:dp[i] = min (dp[i], dp[j-1] + 1); dp[i] 表示前i个字符划分的最少回文串, 如 ...
- UVA 11584
Problem H: Partitioning by Palindromes We say a sequence of characters is a palindrome if it is the ...
- UVA - 11584 划分字符串的回文串子串; 简单dp
/** 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34398 UVA - 11584 划分字符串的回文串子串: 简单 ...
- UVA 11584 Partitioning by Palindromes (字符串区间dp)
题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...
- UVa 11584 - Partitioning by Palindromes(线性DP + 预处理)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 11584 - Partitioning by Palindromes DP
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...
随机推荐
- 典型的检查对float精度理解的代码
-rand()%); vy = ); vz = ); pList_particle[i].m_velocity = Vector3(vx,vy,vz); ... 1,3行代码的vx和vz的值域可以通过 ...
- rqnoj-342-最不听话的机器人-dp
dp[i][j][k][[l]: 执行第i步,执行到点(j,k),方向为l时,用的最大步数. 状态转移根据step[i]转移. #include<stdio.h> #include< ...
- Centos的Inode及Block相关知识
Centos的Inode及Block相关知识 时间:2016-06-04 01:54来源:blog.51cto.com 作者:"tao" 博客 举报 点击:173次 本经验均在Ce ...
- 利用 iptables 命令限制单个端口的并发连接数
iptables -I INPUT -p tcp --dport 11251:11300 -m connlimit --connlimit-above 10 -j REJECT 以上代码意思: 在IN ...
- Linux workqueue工作原理 【转】
转自:http://blog.chinaunix.net/uid-21977330-id-3754719.html 转自:http://bgutech.blog.163.com/blog/static ...
- AVAudioplayer时error解决 创建失败 ERror creating player: Error Domain=NSOSStatusErrorDomain Code=2003334207 "(null)"
AVAudioplayer 有两个初始化方法: 1.[[AVAudioPlayer alloc] initWithData:musicData error&e]; 2.[[AVAudioPla ...
- 安装使用RESTful 框架SLIM方法
相关框架: http://www.golaravel.com 是一个PHP框架,内置名为LUMEN的RESTful API框架,有中文文档, http://lumen.golaravel.com/do ...
- Android内存溢出解决方案(OOM)
众所周知,每个Android应用程序在运行时都有一定的内存限制,限制大小一般为16MB或24MB(视平台而定).因此在开发应用时需要特别关注自身的内存使用量,而一般最耗内存量的资源,一般是图片.音频文 ...
- “wsimport -keep ”生成客户端报错“Use of SOAP Encoding is not supported.”
本来想用 “wsimport -keep ” 生成客户端,结果报错“Use of SOAP Encoding is not supported.” 应该是缺jar包, 闲麻烦就发现了百度经验上的 这个 ...
- 使用percona xtradb cluster的IST方式添加新节点
使用percona xtradb cluster的IST(Incremental State Transfer)特性添加新节点,防止新节点加入时使用SST(State SnapShop Transfe ...