题目:http://blog.csdn.net/winddreams/article/details/44218961求出每一个点为中心的最长字符串,推断该串是不是从开头的回文串。#include #include #include using namespace std ;int p[120000...
分类:
其他好文 时间:
2015-05-15 21:10:51
阅读次数:
109
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.
For example,
"A man, a plan, a canal: Panama" is a palindrome.
"race a car" is not a ...
分类:
其他好文 时间:
2015-05-14 22:10:26
阅读次数:
131
public class Solution { public boolean isPalindrome(int x) { if (x < 0) { return false; } return x == reverse(x); ...
分类:
其他好文 时间:
2015-05-13 12:19:59
阅读次数:
68
题目A palindromic number reads the same both ways. The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.Find the larges...
分类:
其他好文 时间:
2015-05-13 00:51:35
阅读次数:
228
uva 10453 Make Palindrome 题目大意:给出一段字符串,要求求出最少加入几个字符(任意位置),可以让该字符串变成会问字符串,并输出修改以后的回文字符串。 解题思路:dp[i][j]代表了将该字符串从第i位到第j位变成回文字符串最少要添加的字符。当S[i]==S[j],dp[i][j]=dp[i+1][j?1]S[i] == S[j], dp[i][j] = dp[i + 1][...
分类:
其他好文 时间:
2015-05-12 09:35:09
阅读次数:
118
题目大意:给出一个字符串,要求只考虑字符串中的字母和数字,判断该字符串是否是回文。注意:空串是回文。
算法思想:首先将字符串中的大写字母全部转化为小写字母,然后分别设置两个游标Left ,right。开始扫描字符串如果当前字符不是字母或数字则跳过,若是则比较,左右游标指向的字符是否相同,如果不想同则返回FALSE,当扫描完整个字符串的时候返回TRUE。
代码如下:
class Solutio...
分类:
其他好文 时间:
2015-05-11 12:58:19
阅读次数:
116
(没有坑怎么填?)最近膜了一些关于回文串的题目,感到非常有意思,遂开篇记录.在逛UOJ的题目时发现了vfk添上了新题,APIO 2014的题目.本身是一件很正常的事,而它事实上也没有变成什么了不得的事.我看到了Palindrome这个标题---回文串已经烂大街了,没什么新意.不过我很早就向学习回文树...
分类:
其他好文 时间:
2015-05-10 00:54:01
阅读次数:
147
Determine whether an integer is a palindrome. Do this without extra space.思想: 先计算出这个整数的逆序数,然后比较它和原来的数每位是否都相同即可。另外要注意负数没有回文数,还应该考虑overflow一定不是回文数。AC代码:...
分类:
其他好文 时间:
2015-05-09 18:58:58
阅读次数:
121
Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i...
分类:
其他好文 时间:
2015-05-09 07:42:26
阅读次数:
124
题意:
给出增加或减少某个字符的代价。
给你一个串,求让它变成回文串的最小代价。
思路:
和求次数一样。
然后注意的是其实增加和减少的性质是一样的。所以对于每个字符,取修改代价最小的就行了。
意思就是取增加和减少的最小值。
其他就同求次数的区间dp了。
代码:
#include"cstdlib"
#include"cstdio"
#include"cstring"
#includ...
分类:
其他好文 时间:
2015-05-07 16:55:12
阅读次数:
89