Determine whether an integer is a palindrome. Do this without extra space.click to show spoilers.Some hints:Could negative integers be palindromes? (i...
分类:
其他好文 时间:
2014-06-14 08:52:31
阅读次数:
265
题目来源:Light OJ 1258 Making Huge Palindromes
题意:末尾添加最少的字符是使输入的串变成回文 输出长度
思路:直接KMP匹配出它和它反串的最大匹配 n减去它就是要添加的数量
#include
#include
#include
using namespace std;
const int maxn = 1000010;
char a[maxn], ...
分类:
其他好文 时间:
2014-06-05 01:14:56
阅读次数:
240
Determine whether an integer is a palindrome. Do
this without extra space.Some hints:Could negative integers be palindromes? (ie,
-1)If you are thinki...
分类:
其他好文 时间:
2014-05-26 18:07:52
阅读次数:
217
给定一个数,求一个新数要大于等于这个数,而这个新数既要是palindromes回文又要是prime素数。
题目很简单,有人都使用取巧的方法保存好结果直接查表。
或者暴力法求解。
这里不使用保存表的方法,也不要用暴力法。- 这些方法都不好。
使用的技巧有:
1 而是使用next palindrome的技巧,只需要O(n),n是数位,可以认为是常数了。
2 判断素数的方法,时间效率是O(s...
分类:
其他好文 时间:
2014-05-04 09:18:17
阅读次数:
334
Determine whether an integer is a palindrome.
Do this without extra space.Some hints:Could negative integers be palindromes?
(ie, -1)If you are thinki...
分类:
其他好文 时间:
2014-05-01 19:48:19
阅读次数:
344