# include<iostream>
# include<string>
# include<string.h>
# include<queue>
# include<stdio.h>
#include <algorithm>
using namespace std;
int d[][];
int main()
{
int n,m,i,j;
cin>>n;
while(n--)
{
char s1[],s2[];
scanf("%s",s1);
int len = strlen(s1)-;
for(i=len,j=;i>=;i--,j++)
s2[i] = s1[j]; for(i=;i<=len;i++)
{
for(j=;j<=len;j++)
{
if(s1[i]==s2[j])
{
if(i==||j==) d[i][j]= ;
else d[i][j] = d[i-][j-] + ;
}
else
{
if(i==&&j==)
{
d[i][j]= ;
continue;
}
if(i==)
{
d[i][j]= d[i][j-];
continue;
}
if(j==)
{
d[i][j]= d[i-][j];
continue;
}
if(d[i-][j]>=d[i][j-]) d[i][j] = d[i-][j];
else d[i][j] = d[i][j-];
}
}
}
printf("%d\n",len-d[len][len]+);
}
return ;
}

回文字符串 NYOJ的更多相关文章

  1. [NYOJ 37] 回文字符串

    回文字符串 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba".当 ...

  2. nyoj 回文字符串

    回文字符串 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba".当 ...

  3. nyoj 37 回文字符串 【DP】

    先反向复制一个新的字符串,然后再找出最长公共子串,在用长度n减去就可以 回文字符串 时间限制:3000 ms  |  内存限制:65535 KB 难度:4 描写叙述 所谓回文字符串,就是一个字符串,从 ...

  4. nyoj 题目37 回文字符串

    回文字符串 时间限制:3000 ms  |  内存限制:65535 KB 难度:4   描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba".当 ...

  5. [LeetCode] Valid Palindrome 验证回文字符串

    Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignori ...

  6. 回文字符串的判断!关于strlen(char * str)函数

    #include <stdio.h> #include <string.h> int ishuiw(char * p); int main() { ;//true-false接 ...

  7. NYOJ_37.回文字符串 (附滚动数组)

    时间限制:3000 ms  |  内存限制:65535 KB 难度:4 描述 所谓回文字符串,就是一个字符串,从左到右读和从右到左读是完全一样的,比如"aba".当然,我们给你的问 ...

  8. 131. 132. Palindrome Partitioning *HARD* -- 分割回文字符串

    131. Palindrome Partitioning Given a string s, partition s such that every substring of the partitio ...

  9. leetcode:Longest Palindromic Substring(求最大的回文字符串)

    Question:Given a string S, find the longest palindromic substring in S. You may assume that the maxi ...

随机推荐

  1. js---手机端滑动进度条

    最近做项目,有一个滑动音乐播放进度条的效果,但是使用input的 range 来做会出现一些问题,想了想还是用JS来写.直接上代码: <!doctype html> <html la ...

  2. js document.activeElement 获得焦点的元素

    <body> <input type="text" id="test" value="ajanuw"> <sc ...

  3. 中小学教育缴费----支付宝回传数据.net core 接收中文乱码

    问题描述: 中小学教育缴费,发送账单到家长支付宝,家长支付成功之后,支付宝回传数据,验签的时候失败了,排查之后发现账单名称乱码了.支付宝回传的时候中文传的是GBK编码格式,但是我接收的是%D5˵%A5 ...

  4. poj3613 Cow Relays【好题】【最短路】【快速幂】

    Cow Relays Time Limit: 1000MS   Memory Limit: 65536K Total Submissions:9207   Accepted: 3604 Descrip ...

  5. 网龙“MAD技术论坛”在榕举办 200余位技术人才共话“改变教育”

    9月16日,由网龙网络公司主办.msup协办的“MAD技术论坛”在榕举办,来自美国.香港.苏州等地的技术大牛受邀来到福州,围绕“Make a difference to education”这一论坛主 ...

  6. Codeforces 180C - Letter - [简单DP]

    题目链接:http://codeforces.com/problemset/problem/180/C 题意: 有一段字符串,包含大小写字母,每次可以将其中一个字母由大写变成小写,或者小写变成大写.要 ...

  7. express+gulp+gulp-nodemon+browser-sync自动刷新

    express自动生成项目.不在赘述 1.在项目根目录下新建终端,依次运行如下命令 npm install gulp --save-dev npm install gulp-nodemon --sav ...

  8. rtd1296 mtd 设备驱动分析

    mtd 分区一般采用3种方式实现 1.内核写死  mtd_partition 2.u-boot 传参 为了使kernel能够解析mtdparts信息,我们需要将内核中的Device Drivers - ...

  9. goreplay,tcpcopy

    流量拷贝工具试用 https://github.com/buger/goreplaynginx mirror openresty 通过lua tcpcopy 支持 HTTP 请求的录制和重放,可以在线 ...

  10. [skill][c] *(char**)

    /* scmp: string compare of *p1 and *p2 */ int scmp(const void *p1, const void *p2) { char *v1, *v2; ...