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

  1. 【Uva 11584】Partitioning by Palindromes

    [Link]:https://cn.vjudge.net/contest/170078#problem/G [Description] 给你若干个只由小写字母组成的字符串; 问你,这个字符串,最少能由 ...

  2. 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 ...

  3. uva 11584 Partitioning by Palindromes 线性dp

    // uva 11584 Partitioning by Palindromes 线性dp // // 题目意思是将一个字符串划分成尽量少的回文串 // // f[i]表示前i个字符能化成最少的回文串 ...

  4. 区间DP UVA 11584 Partitioning by Palindromes

    题目传送门 /* 题意:给一个字符串,划分成尽量少的回文串 区间DP:状态转移方程:dp[i] = min (dp[i], dp[j-1] + 1); dp[i] 表示前i个字符划分的最少回文串, 如 ...

  5. UVA 11584

    Problem H: Partitioning by Palindromes We say a sequence of characters is a palindrome if it is the ...

  6. UVA - 11584 划分字符串的回文串子串; 简单dp

    /** 链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=34398 UVA - 11584 划分字符串的回文串子串: 简单 ...

  7. UVA 11584 Partitioning by Palindromes (字符串区间dp)

    题目链接:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem ...

  8. UVa 11584 - Partitioning by Palindromes(线性DP + 预处理)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  9. UVA 11584 - Partitioning by Palindromes DP

    http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&p ...

随机推荐

  1. 好用的 diskpart 命令,操作磁盘分区,并创建 EFI 引导分区

    进入 win8 pe, 或在安装 win8 选择安装磁盘分区时按 shift+F10,都是可能用到 diskpart 去操作的时候. 进入cmd后, diskpart 进入 list disk---- ...

  2. JSP01

    <%@page pageEncoding="UTF-8"    //page:设置此文件的编码 contentType="text/html;charset=utf ...

  3. TreeView htc 改写

    call the function loadTree(treeviewId) when body is loaded <body onload="loadTree('tvSelect' ...

  4. 【Pro ASP.NET MVC 3 Framework】.学习笔记.7.SportsStore:购物车

    3 创建购物车 每个商品旁边都要显示Add to cart按钮.点击按钮后,会显示客户已经选中的商品的摘要,包括总金额.在购物车里,用户可以点击继续购物按钮返回product目录.也可以点击Check ...

  5. Swoole 遇上 PHP会是怎样的结果呢

    一直想写点Swoole的东西,毕竟它重新定义了php,却一直不知道怎么下手写 Swoole涉及的知识点非常多,互为表里,每次想写都发现根本理不出一个头绪 Swoole是一个php的扩展,它的核心目的就 ...

  6. hdwiki 软件包结构

    HDWiki软件包结构转载自http://www.chinabaike.com/z/shenghuo/pc/2011/0414/814308.html           根目录下的PHP文件     ...

  7. [ios][opengles]opengles在ios上的透明问题

    关于透明,OpenGL/ES 中可以通过 blend (混色) 来简单实现,混色的基本原理就是把要绘制的物体的颜色与屏幕上已经绘制好的颜色以一定比例来混合,最后的颜色看上去就像半透明一样.要使用混合先 ...

  8. initComponents()方法

    initComponents()是在使用GUI工具设计GUI界面时,NetBeans系统自动生成的方法. 其功能是在界面添加各个组件,并为它们注册监听器. 把initComponents()放在构造方 ...

  9. CSS select样式列表-------美化列表

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  10. SecureCRT issue "Could not open clipboard: Assess is denied" (无法打开粘贴板:访问被拒绝)

    I got an issue when copying some line/word (actually just select the context ) in the Linux terminal ...