一、题目DescriptionWangpeng is good at drawing. Now he wants to say numbers like “521” to his girlfriend through the game draw something.Wangpeng can’t wr...
分类:
其他好文 时间:
2014-07-22 22:53:15
阅读次数:
242
Determine whether an integer is a palindrome. Do this without extra space.
判断一个int值是否为回文数。
本题有几点需要注意:
(1)不能用额外存储空间,也就是说只能用常数空间解决;诸如将int转换为string再去比较字符是不可行的;
(2)判断回文数的方法有两个:从中间开始向两头判断、从两头向中间判断;后者更简...
分类:
其他好文 时间:
2014-07-19 23:22:39
阅读次数:
345
Problem DescriptionWangpeng is good at drawing. Now he wants to say numbers like “521” to his girlfriend through the game draw something.Wangpeng can’...
分类:
其他好文 时间:
2014-07-19 18:24:12
阅读次数:
205
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return all possible palindrome partitioning ofs.For example, giv...
分类:
其他好文 时间:
2014-07-19 14:20:14
阅读次数:
178
Power of Fibonacci
Time Limit: 5 Seconds Memory Limit: 65536 KB
In mathematics, Fibonacci numbers or Fibonacci series or Fibonacci sequence are the numbers of the following integer sequence...
分类:
其他好文 时间:
2014-07-19 11:48:45
阅读次数:
239
给一字符串,问最少加几个字符可以让它成为回文串
比如 Ab3bd 最少需要两个字符可以成为回文串 dAb3bAd
思路:
动态规划 DP[i][j] 意味着从 i 到 j 这段字符变为回文串最少要几个字符,枚举子串长。
if str[i] == str[j]:
DP[i][j] = DP[i + 1][j - 1]
else:
DP[i][j] = min( DP[i +...
分类:
其他好文 时间:
2014-07-19 02:35:45
阅读次数:
198
边吃边敲,效率就是高
代码如下:
#include
#include
#define MAX 1000050
char s[MAX],ss[MAX*2];
int p[MAX*2];
int min(int a,int b){return a>b?b:a;}
int main()
{
int i,id,mx,max,n,j;
j=1;
while(scanf("%s",s...
分类:
其他好文 时间:
2014-07-19 02:31:25
阅读次数:
166
Given a strings, partitionssuch that every substring of the partition is a palindrome.Return the minimum cuts needed for a palindrome partitioning ofs...
分类:
其他好文 时间:
2014-07-19 00:05:43
阅读次数:
200
DZY Loves Fibonacci NumbersTime Limit:4000MSMemory Limit:262144KB64bit IO Format:%I64d & %I64uSubmitStatusAppoint description:DescriptionIn mathematic...
分类:
其他好文 时间:
2014-07-18 19:05:07
阅读次数:
305