Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-04-07 21:31:44
阅读次数:
120
题意:
给一个数n,求有多少种和为n的单峰先增序列,比如当n=5时结果为3:(5), (1 3 1), (1 1 1 1 1)。
分析:
转化为求类似整数拆分问题,f(i,j)的意义是把i进行拆分,最大数小于等于j的方法数。
代码:
//poj 1221
//sep9
#include
using namespace std;
const int maxN=300;
__int64 a...
分类:
其他好文 时间:
2015-04-06 21:57:14
阅读次数:
118
Longest Palindromic Substring问题:Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and th...
分类:
其他好文 时间:
2015-04-03 17:06:38
阅读次数:
112
题目:
Given a string S,
find the longest palindromic substring in S.
You may assume that the maximum length of S is
1000, and there exists one unique longest palindromic substring.
思路:第一种思路,就是以某...
分类:
其他好文 时间:
2015-04-01 09:30:28
阅读次数:
115
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-03-30 22:49:58
阅读次数:
162
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-03-22 00:18:36
阅读次数:
134
O(n2): 1 class Solution { 2 public: 3 string getP(string s, int start, int end) { 4 while (start >= 0 && end result.size()) result = s1;1...
分类:
其他好文 时间:
2015-03-20 08:05:24
阅读次数:
123
A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number...
分类:
其他好文 时间:
2015-03-18 20:27:57
阅读次数:
131
Given a stringS, find the longest palindromic substring inS. You may assume that the maximum length ofSis 1000, and there exists one unique longest pa...
分类:
其他好文 时间:
2015-03-11 21:29:40
阅读次数:
112
题意:
找一个小于N的最大的且符合题意的数。
题意的数为,通过缩减后是回文的数,所谓的缩减就是相同连续的数看做一个数,如“155451111”其实就是“15451”是符合题意的数。
思路:
通过数位dp,然后二分求解。
dp[i][j][k]代表第i位,已经放了j个数,最后长度是k的缩减回文数有几个。
然后需要一个ok[]数组代表放的数是什么,如果连续放相同的数就等于没放数。
遍历所...
分类:
其他好文 时间:
2015-03-11 19:45:12
阅读次数:
140