码迷,mamicode.com
首页 >  
搜索关键字:humble numbers    ( 7694个结果
HDU 1058 Humble Numbers
既然将这道题分类到动态规划的题目里面,一开始便是用动态规划的思想去思考。一个上午毫无突破,看的人家的题解。定义四个伪指针存放下标,分别表示的意思是在已知的丑数中,能够与2,3,5,7相乘的最小的数的下标。上面这句话要好好体会。也就是说dp[p1] * 2 能够得到一个新的丑数,其他三个以此类推。但我...
分类:其他好文   时间:2014-07-06 20:41:32    阅读次数:223
【题解】【数组】【Prime and composite numbers】【Codility】Peaks
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
【题解】【数组】【Prime and composite numbers】【Codility】Flags
Find the maximum number of flags that can be set on mountain peaks.
分类:其他好文   时间:2014-07-06 15:07:09    阅读次数:371
Decode Ways
A message containing letters from A-Z is being encoded to numbers using the following mapping:'A' -> 1'B' -> 2...'Z' -> 26Given an encoded message con...
分类:其他好文   时间:2014-07-06 14:42:59    阅读次数:150
hdu1058 Humble Numbers(丑数)
丑数:只包含一定的质因子的数称丑数,例如包含2,3,5.我们就把2,3,4,5,6,8,9,10,12,15.......。但我们通常把1称作为第一个丑数。解题思路:我们现在做的这道题,就是以2,3,5,7为质因子,要我们求第n个丑数(以1为第一个丑数),可以采用DP的思想来解决。我们先以ar...
分类:其他好文   时间:2014-07-06 14:12:48    阅读次数:153
POJ 2309 BST 树状数组基本操作
DescriptionConsider an infinite full binary search tree (see the figure below), the numbers in the nodes are 1, 2, 3, .... In a subtree whose root nod...
分类:其他好文   时间:2014-07-06 13:23:06    阅读次数:229
LeetCode:Combinations
Given two integers n and k, return all possible combinations of k numbers out of 1 ...n.For example,If n = 4 and k = 2, a solution is:[ [2,4], [3,4...
分类:其他好文   时间:2014-07-05 22:10:53    阅读次数:226
[Leetcode][Tree][Sum Root to Leaf Numbers]
非常简单的一个题,和path sum非常类似。 1 /** 2 * Definition for binary tree 3 * struct TreeNode { 4 * int val; 5 * TreeNode *left; 6 * TreeNode *rig...
分类:其他好文   时间:2014-07-05 22:03:48    阅读次数:251
uva 11105 - Semi-prime H-numbers(数论)
题目链接: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
uva 10539 - Almost Prime Numbers(数论)
题目链接: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
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!