摘要: 加了L才是long,不加L是int。 1 public class test { 2 public static void main(String[] args) { 3 System.out.println(primeFactor(600851475143L)); 4 } 5 6 public static long primeFactor(long source) { 7 long start = (long) Math.floor(Math.sqrt(source)); 8 9 for (... 阅读全文
posted @ 2013-12-05 23:58 Chihane 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 1 import math 2 3 def primeFactor(source): 4 start = int(math.floor(math.sqrt(source))) 5 6 while start > 1: 7 print start 8 mod = source % start 9 if mod == 0 and isPrime(start):10 return start11 start -= 112 13 def isPrime(source):... 阅读全文
posted @ 2013-12-05 22:36 Chihane 阅读(145) 评论(0) 推荐(0) 编辑
摘要: 装在java.util.Collections里边。 几个静态方法: reverse():懂。 sort():懂。 shuffle():挺方便的方法,如字面意思,洗牌。 swap():也挺方便的方法,交换两个项,接收三个参数,第一个懂,第二第三是下标值,如果相同列表不变,真挺方便的。 fill():还是挺方便的,接收两个参数,第一个懂,第二个是想填的对象,说不定什么时候就能用到。 copy():依旧方便,拷贝列表,接收两个参数,第一个是目标,第二个是来源。如果第一个小,第二个其他部分不变;如果第二个小,抛异常。 binarySearch():二分... 阅读全文
posted @ 2013-12-05 19:44 Chihane 阅读(145) 评论(0) 推荐(0) 编辑