一、题目: 把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。 二、思路: en.....自己想不出来,还是抄袭别人的吧。 三、代码: ...
分类:
其他好文 时间:
2018-08-10 18:01:43
阅读次数:
149
在交互式解释器中输入 import this 就会显示 Tim Peters 的 The Zen of Python The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than imp ...
分类:
编程语言 时间:
2018-07-30 14:37:49
阅读次数:
569
A - Arpa’s hard exam and Mehrdad’s naive cheat CodeForces - 742A There exists an island called Arpa’s land, some beautiful girls live there, as ugly o ...
分类:
其他好文 时间:
2018-07-25 18:59:41
阅读次数:
159
Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, ... shows the first 11 ugly numbers. ...
分类:
其他好文 时间:
2018-07-23 14:39:02
阅读次数:
134
题目 把只包含质因子2、3和5的数称作丑数(Ugly Number)。例如6、8都是丑数,但14不是,因为它包含质因子7。 习惯上我们把1当做是第一个丑数。求按从小到大的顺序的第N个丑数。 思路 显然每个数判断不可取,计算量超级大。 我们要用前面的丑数来生成后面的丑数 从1开始,记三个指针t1,t2 ...
分类:
其他好文 时间:
2018-07-21 19:51:21
阅读次数:
143
def isUgly(num): """ :type num: int :rtype: bool """ if num>0: if num in [1,2,3,5]: return True else: res =True for i in [2,3,5]: if num%i==0: res = i ...
分类:
其他好文 时间:
2018-07-21 11:42:11
阅读次数:
94
import this The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex i... ...
分类:
其他好文 时间:
2018-07-19 17:31:46
阅读次数:
143
Beautiful is better than ugly. 优美胜于丑陋 Explicit is better than implicit. 明了胜于晦涩 Simple is better than complex. 简单胜过复杂 Complex is better than complicate ...
分类:
编程语言 时间:
2018-07-13 22:22:50
阅读次数:
223
The Zen of Python, by Tim Peters Beautiful is better than ugly. Explicit is better than implicit. Simple is better than complex. Complex is better tha ...
分类:
编程语言 时间:
2018-06-24 16:04:59
阅读次数:
172
>>> import thisThe Zen of Python, by Tim PetersBeautiful is better than ugly.Explicit is better than implicit.Simple is better than complex.Complex is ...
分类:
编程语言 时间:
2018-06-16 23:00:48
阅读次数:
226