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. MySQL flush tables with read lock

    mysql> flush tables with read lock; flush tables with read lock 会去关闭已经打开的所有文件,它要做这个操作就先要拿到锁:当发起这个 ...

  2. div 居中进行总结

    1.margin:auto ;让元素居中,需要确定元素的宽度,并且需要是块元素 eg: div { width:200px; height:200px; background:#222; margin ...

  3. S3C2440 驱动程序开发

    转载:http://www.cnblogs.com/lishixian/articles/2999923.html

  4. Itext 中的文本信息绝对定位

    PdfContentByte pcb = pw.getDirectContent(); pcb.beginText(); pcb.setFontAndSize(bfChinese, 12); pcb. ...

  5. IIS Express 的 applicationhost.config配置文件

    文件所在目录 C:\Users\admin\Documents\IISExpress\config 或者 C:\Program Files\IIS Express\AppServer\ //加载语言文 ...

  6. 开机启动tomcat

    windows: 成功之后在dos窗口键入 service.bat install Tomcat 输完然后按Enter键,出现如下窗口,便成功了. 进入windows服务管理,设成是自动的. #chk ...

  7. NOI2015 小园丁与老司机

    http://uoj.ac/problem/132 这道题前2行的输出比较容易,就是简单的动态规划,然后第3行就是比较少见的有上下界的最小流. 前2行比较容易,我们讨论一下第3行的解法吧. 比如第1个 ...

  8. 第36讲 activityForResult

    第36讲 activityForResult activityForResult的作用是利用下一个activity给当前的activity传值(前一讲是利用当前activity给下一个activity ...

  9. JAVA泛型编程笔记

    1介绍 Java泛型编程是JDK1.5版本后引入的.泛型让编程人员能够使用类型抽象,通常用于集合里面. 下面是一个不用泛型例子: List myIntList=new LinkedList(); // ...

  10. 为MyEclipse加入自己定义凝视

    非常多时候我们默认的MyEclipse的类凝视是这种,例如以下图 能够通过改动MyEclipse的凝视规则来改变,不但能够改动类的.还能够改动字段.方法等凝视规则,操作方法例如以下 1.针对方法的凝视 ...