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 #熟悉这种调用方法

 def main():
t = int(raw_input())
for i in range(t):
print factorial(int(raw_input())) main()

学习

  怎么调用外部的库  

错误

  函数忘了return, 思路不严谨

  读取时候忘了类型转换

    py的类型转化更为注意,比起有类型规定的C

Small factorials Solved Problem code: FCTRL2的更多相关文章

  1. Factorial Solved Problem code: FCTRL

    import sys #import psyco #很奇怪,这题用psyco就runtime error #psyco.full() def z(n): #这个应该是技巧的一种算法 r = 0 whi ...

  2. ATM Solved Problem code: HS08TES

    # ATM import sys withdraw, balance = map(float, sys.stdin.readline().strip().split()) # strip()用法去除结 ...

  3. Double Strings Solved Problem code: DOUBLE

    # Fuking silly, OTZ.... import sys def main(): n = int(raw_input()) for num in sys.stdin: if int(num ...

  4. Enormous Input Test Solved Problem code: INTEST

    import sys import psyco #一键优化库 psyco.full() def main(): n, k = map(int, sys.stdin.readline().strip() ...

  5. Cooking Schedule Problem Code: SCHEDULE(优先队列)

    Cooking Schedule Problem Code: SCHEDULE Chef is a well-known chef, and everyone wishes to taste his ...

  6. Holes in the text Add problem to Todo list Problem code: HOLES

    import sys def count_holes(letter): hole_2 = ['A', 'D', 'O', 'P', 'Q', 'R'] if letter == 'B': return ...

  7. The Lead Game Add problem to Todo list Problem code: TLG

    '''def count_lead(first, second): if first > second: return 1, first - second elif first == secon ...

  8. Turbo Sort Add problem to Todo list Problem code: TSORT

    def heap_sort(ary): n = len(ary) first = int(n / 2 - 1) for start in range(first, -1, -1): # 3~0 rev ...

  9. Use Spring Insight Developer to Analyze Code, Install it with Tomcat, and Extend it with Plugins--转载

    原文地址:http://www.tomcatexpert.com/blog/2012/12/05/use-spring-insight-developer-analyze-code-install-i ...

随机推荐

  1. ie6兼容性

    文本重复Bug 在IE6中,一些隐藏的元素(如注释.display:none;的元素)被包含在一个浮动元素里,就有可能引发文本重复bug.解决办法:给浮动元素添加display:inline;. 躲猫 ...

  2. Python 升级

    1.到官网下载对于的版本: 2.下载之后并解压出来,编译: tar xf python.xx.xx.tar.xz sudo mkdir /usr/local/python ./configure -- ...

  3. iOS学习之下拉刷新

    今天我们来给昨天的Demo加上下拉刷新和上拉加载更多的功能. 1.下拉刷新. 在viewDidLoad中调用方法addRefreshControl,下拉时可以出现风火轮加载更多的效果. - (void ...

  4. HTML5实现的视频播放器01

    HTML5实现的视频播放器   什么是hivideo? 最近一段时间在使用PhoneGap开发一个App应用,App需要播放视频,本想直接使用html5的video,但使用它在全屏播放时不支持横屏播放 ...

  5. BZOJ 2115: [Wc2011] Xor

    2115: [Wc2011] Xor Time Limit: 10 Sec  Memory Limit: 259 MB Submit: 2794  Solved: 1184 [Submit][Stat ...

  6. Codeforces 568B Symmetric and Transitive

    http://codeforces.com/contest/568/problem/B 题意:题意还挺绕的,其实就是说:要你求出一个图,要求保证其中有至少一个点不连任何边,然后其他连边的点构成的每个联 ...

  7. Codeforces 429B Working out

    http://codeforces.com/contest/429/problem/B 题意:一个从左下到右上,一个从左上到右下,要求只相交一次,求整个路径和的最大值 思路:发现可以枚举交点,然后算到 ...

  8. 【转】解决java.lang.IllegalStateException: The content of the adapter has changed but ListView...的问题

    原文网址:http://blog.csdn.net/ueryueryuery/article/details/20607845 我写了一个Dialog,Dialog中有一个ListView,想要点Li ...

  9. 使用Python做科学计算初探

    今天在搞定Django框架的blog搭建后,尝试一下python的科学计算能力. python的科学计算有三剑客:numpy,scipy,matplotlib. numpy负责数值计算,矩阵操作等: ...

  10. MyEclipse第一个Servlet程序 --解决Win7系统下MyEclipse与Tomcat连接问题

    前言 本文旨在帮助学习java web开发的人员,熟悉环境,在Win7系统下运行自己的第一个Servlet程序,因为有时候配置不当或系统原因可能会运行不成功,这给初学者带来了一定烦恼,我也是为此烦恼过 ...