题目:Implement next permutation, which rearranges numbers into the lexicographically next greater permutation of numbers.If such arrangement is not poss...
分类:
其他好文 时间:
2014-07-07 10:57:23
阅读次数:
175
既然将这道题分类到动态规划的题目里面,一开始便是用动态规划的思想去思考。一个上午毫无突破,看的人家的题解。定义四个伪指针存放下标,分别表示的意思是在已知的丑数中,能够与2,3,5,7相乘的最小的数的下标。上面这句话要好好体会。也就是说dp[p1] * 2 能够得到一个新的丑数,其他三个以此类推。但我...
分类:
其他好文 时间:
2014-07-06 20:41:32
阅读次数:
223
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:
其他好文 时间:
2014-07-06 16:45:00
阅读次数:
201
Divide an array into the maximum number of same((-))sized blocks, each of which should contain an index P such that A[P - 1] A[P + 1].
分类:
其他好文 时间:
2014-07-06 15:30:31
阅读次数:
465
Find the maximum number of flags that can be set on mountain peaks.
分类:
其他好文 时间:
2014-07-06 15:07:09
阅读次数:
371
Determine whether an integer is a palindrome. Do this without extra space.
Some
hints:
Could negative integers be palindromes? (ie, -1)
If you are thinking of converting the integer to string...
分类:
其他好文 时间:
2014-07-05 10:44:29
阅读次数:
227
题目链接:uva 11105 - Semi-prime
H-numbers
题目大意:H-number为4?k+1(k为非负数),H-composites为因子中含有H-number(不包括自己本身)的数,反之久是H-prime,给定n,求有多少H-composites。
解题思路:首先用筛选法求出范围内的H-prime,然后枚举两个判断乘积是否在范围内。
#include
#...
分类:
其他好文 时间:
2014-07-04 00:26:37
阅读次数:
248
Given a string, determine if it is a palindrome, considering only alphanumeric characters and ignoring cases.For example,"A man, a plan, a canal: Pana...
分类:
其他好文 时间:
2014-07-03 19:38:58
阅读次数:
287
题目链接:uva 10539 - Almost Prime Numbers
题目大意:给出范围low~high,问说在这个范围内有多少个数满足n=pb,(p为素数).
解题思路:首先处理出1e6以内的素数,然后对于每个范围,用solve(high)?solve(low?1),solve(n)用来处理小于n的满足要求的数的个数。枚举素数,判断即可。
#include
#include...
分类:
其他好文 时间:
2014-07-03 16:50:09
阅读次数:
190
题目
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" i...
分类:
其他好文 时间:
2014-07-02 09:49:04
阅读次数:
271