清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>
#coding:utf8 import time import os global_list = [] def test1(n): if n==1 or n==2: return 1 else: return test1(n-1) + test1(n-2) def test2(n): global global_list if n==1 or n==2: return 1 else: temp = test2(n-1) + test2(n-2) if isinstance(temp,int): global_list.append(temp) return temp def main(): global global_list input_int = raw_input("Entry your number:") length = int(input_int) #第一种方法 start = time.clock() for i in xrange(length): print test1(i+1 ), end = time.clock() print os.linesep + "处理耗时:%f s"%(end-start) #第二种方法 start = time.clock() test2(length) temp_set = set(global_list) global_list = [i for i in temp_set] global_list.sort(reverse=True) global_list.extend([1,1]) for i in global_list[::-1]: print i, end = time.clock() print os.linesep + "处理耗时:%f s"%(end-start) if __name__ == "__main__": main()