#列表解析#编写0到10之间的偶数#方法1#结果:[0,2,4,6,8]num=range(10)num1=len(num)evens=[]i=0whilei<num1:ifi%2==0:evens.append(i)i+=1printevens#方法2print[(i)foriinrange(10...
分类:
编程语言 时间:
2014-08-19 00:51:03
阅读次数:
205
1. range与xrangerange([start,]stop[,step])range可以创建一个从start到stop(不包含)的列表,用在循环中时,会一次性把列表都加载到内存中。xrange([start,]stop[,step])xrange可以创建一个从start到stop(不包含)的...
分类:
编程语言 时间:
2014-08-19 00:50:13
阅读次数:
344
The binomial coefficient C(m,n) is defined as
m!
C(m,n) = --------
n!(m-n)!
Given four natural numbers p, q, r, and s, compute the the result of dividing
C(p,q) by C(r,s).
T...
分类:
其他好文 时间:
2014-08-18 23:37:43
阅读次数:
274
先是想筛法素数表啊,然后1~2000000000枚举打表啊,结果越想越不对。
后来想到唯一分解定理,可是怎么实现呢。。果然还是需要努力啊。。
研究了discuss代码,码之~
~~~~
dp的思想,若dp[i]是Humble Numbers,那么dp[i]*2,dp[i]*3,dp[i]*5,dp[i]*7都将是Humble Numbers。
所以只需要注意连续性便好了。
#inclu...
分类:
其他好文 时间:
2014-08-18 18:32:52
阅读次数:
166
1 class test(object): 2 def rangetest(self): 3 for i in range(2,0,-1): 4 print i 5 print i 6 i=2 7 wh...
分类:
编程语言 时间:
2014-08-18 18:27:12
阅读次数:
247
A pair of numbers has a unique LCM but a single number can be the
LCM of more than one possible pairs. Forexample 12 is the
LCM of (1, 12), (2, 12),
(3,4) etc. For a given positive integer N, the ...
分类:
其他好文 时间:
2014-08-18 16:25:24
阅读次数:
240
Given a collection of candidate numbers (C) and a target number (T), find all unique combinations in C where the candidate numbers sums to T....
分类:
其他好文 时间:
2014-08-17 17:03:22
阅读次数:
184
We have seen built-in functions that take a variable number of arguments. For example range can take one, two or three arguments.It is possible to wri...
分类:
其他好文 时间:
2014-08-17 16:52:32
阅读次数:
272
只攻击正前方的单位,向前发射一条射线,攻击碰到的单位RaycastHit hit;//range 射线的长度,即攻击范围,maskTarget敌方单位的mask,只攻击敌方单位if(Physics.Raycast(unit.thisT.position, unit.thisT.forward, ou...
分类:
其他好文 时间:
2014-08-17 11:39:02
阅读次数:
218
列表推导与生成器表达式当我们创建了一个列表的时候,就创建了一个可以迭代的对象:>>> squares=[n*n for n in range(3)]>>> for i in squares: print i 014这种创建列表的操作很常见,称为列表推导。但是像列表这样的迭代器,比如str、file等...
分类:
编程语言 时间:
2014-08-17 01:05:01
阅读次数:
330