2015年5月18日
摘要: Link: https://www.hackerrank.com/challenges/even-tree 1 def search(a,b): # 根据核心算法和题目要求要筛选边 2 seen = {} 3 seen[a] = True 4 q = [] 5 6 ... 阅读全文
posted @ 2015-05-18 10:50 sangocare 阅读(150) 评论(0) 推荐(0) 编辑
摘要: 1 def main(): 2 3 r,c = map(int, raw_input().split(' ')) 4 5 if r % 2 != 0: 6 base = 5*(r-1) 7 else: 8 base = 5*(r-2) +... 阅读全文
posted @ 2015-05-18 10:19 sangocare 阅读(91) 评论(0) 推荐(0) 编辑
摘要: 1 def main(): 2 3 t = int(raw_input()) 4 5 for _ in xrange(t): 6 s = raw_input().strip() 7 s_len = len(s) 8 is_funn... 阅读全文
posted @ 2015-05-18 09:25 sangocare 阅读(125) 评论(0) 推荐(0) 编辑
摘要: fib = {}f = [1, 1]fib[1] = Truewhile f[-1] < 1e10: # 不断的计算,然后加在尾部,最后比对“in” f.append(f[-1]+f[-2]) fib[f[-1]] = TrueT = input()for i in xrange(T):... 阅读全文
posted @ 2015-05-18 09:23 sangocare 阅读(174) 评论(0) 推荐(0) 编辑
摘要: Link: https://www.hackerrank.com/challenges/kaprekar-numbers 1 from __future__ import print_function 2 3 4 def find_kaprekar(num): 5 6 num_squ... 阅读全文
posted @ 2015-05-18 08:44 sangocare 阅读(231) 评论(0) 推荐(0) 编辑