Factorial Solved Problem code: FCTRL】的更多相关文章

import sys #import psyco #很奇怪,这题用psyco就runtime error #psyco.full() def z(n): #这个应该是技巧的一种算法 r = 0 while 5 <= n: n /= 5 r += n return r def main(): n = int(sys.stdin.readline()) for t in sys.stdin: #这种循环输入一点问题也没 print z(int(t)) #输入的是String, 一定要记得int转化…
import sys def fact(n): final = n while n > 1: final *= n - 1 n -= 1 return final #逻辑严谨,不要忘了return def main(): t = int(sys.stdin.readline()) for n in sys.stdin: print fact(int(n)) #读取String的转换是一个常见的坑 main() //第二种,利用现成的库 from math import factorial #熟悉…
# ATM import sys withdraw, balance = map(float, sys.stdin.readline().strip().split()) # strip()用法去除结尾的\n符号 if int(withdraw) % 5 != 0 or balance < (withdraw + 0.5): # 1.注意手续费,缺少手续费也不能取 2.xy0~2000是测试值要求,不用判断 print("%.2f" % balance) else: print(…
# Fuking silly, OTZ.... import sys def main(): n = int(raw_input()) for num in sys.stdin: if int(num) % 2 == 0: print int(num) else: # 千万不要忘了考虑奇数的情况 print int(num) -1 main() 学习 化繁为简 逻辑上的理解正确和化繁为简,是刷OJ的第一步,比如本题,一堆废话,其实水爆 输入缓冲流 stdin这种输入就是缓冲流的使用 判断奇偶 模…
import sys import psyco #一键优化库 psyco.full() def main(): n, k = map(int, sys.stdin.readline().strip().split()) #两位数输入的复用 count = 0 for t in sys.stdin: #注意这个for循环方式 if int(t) % k == 0: count += 1 print '%d' % count #注意格式输出 main() #写成函数的格式是一个良好的习惯 学到 py…
Cooking Schedule Problem Code: SCHEDULE Chef is a well-known chef, and everyone wishes to taste his dishes. As you might know, cooking is not an easy job at all and cooking everyday makes the chef very tired. So, Chef has decided to give himself some…
import sys def count_holes(letter): hole_2 = ['A', 'D', 'O', 'P', 'Q', 'R'] if letter == 'B': return 2 elif letter in hole_2: return 1 else: return 0 def main(): n = int(sys.stdin.readline()) for t in sys.stdin: num = 0 for l in t[:-1]: num += count_…
'''def count_lead(first, second): if first > second: return 1, first - second elif first == second: # 题目中没有说明相等的情况 return 0, 0 else: return 2, second - first''' def main(): n = int(raw_input()) lead = 0 winner = 0 # 有些初始值不放置,判断不成立而输出时,为空了就 num1 = 0 n…
def heap_sort(ary): n = len(ary) first = int(n / 2 - 1) for start in range(first, -1, -1): # 3~0 revese max_heapify(ary, start, n - 1) # from start for end in range(n - 1, 0, -1): ary[end], ary[0] = ary[0], ary[end] max_heapify(ary, 0, end - 1) retur…
原文地址:http://www.tomcatexpert.com/blog/2012/12/05/use-spring-insight-developer-analyze-code-install-it-tomcat-and-extend-it-plugins People are still discovering the benefits of the free tool from VMware SpringSource, called Spring Insight Developer. T…