Small factorials Solved Problem code: FCTRL2
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的更多相关文章
- Factorial Solved Problem code: FCTRL
import sys #import psyco #很奇怪,这题用psyco就runtime error #psyco.full() def z(n): #这个应该是技巧的一种算法 r = 0 whi ...
- ATM Solved Problem code: HS08TES
# ATM import sys withdraw, balance = map(float, sys.stdin.readline().strip().split()) # strip()用法去除结 ...
- 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 ...
- Enormous Input Test Solved Problem code: INTEST
import sys import psyco #一键优化库 psyco.full() def main(): n, k = map(int, sys.stdin.readline().strip() ...
- Cooking Schedule Problem Code: SCHEDULE(优先队列)
Cooking Schedule Problem Code: SCHEDULE Chef is a well-known chef, and everyone wishes to taste his ...
- 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 ...
- 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 ...
- 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 ...
- 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 ...
随机推荐
- 向asp.net项目中添加控件AspNetPager
1.打开项目,把.dll文件放入项目中: 2.在工具栏中添加一个自定义选项卡
- 遗传算法matlab实现
我是小鸭酱,博客地址为:http://www.cnblogs.com/xiaoyajiang 以下运用MATLAB实现遗传算法: clc clear %参数 a = 0 ; b = 4 ; e ...
- 用js 做大图轮播方法(一)
//html部分 <div id="wrap"> <div id="slider"> <a target="_blank ...
- TestNG基本注解(注释)
传统的方式来表示JUnit3中的测试方法是测试自己的名字前缀.标记一个类中的某些方法,具有特殊的意义,这是一个非常有效的方法,但命名不很好的扩展(如果我们想添加更多标签为不同的框架?),而非缺乏灵活性 ...
- JAVA在线基础教程!
http://www.runoob.com/java/java-tutorial.html http://www.51zxw.net/list.aspx?cid=380 http://www.weix ...
- 转:DesiredCapabilities内容详解--Appium服务关键字
## Appium 服务关键字 <expand_table> |关键字|描述|实例| |----|-----------|-------| |`automationName`|你想使用的自 ...
- [ES6] ITERATORS
Iterables return an iterator object. This object knows how to access items from a collection 1 at a ...
- Unity 对象池的使用
在游戏开发过程中,我们经常会遇到游戏发布后,测试时玩着玩着明显的感觉到有卡顿现象.出现这种现象的有两个原因:一是游戏优化的不够好或者游戏逻辑本身设计的就有问题,二是手机硬件不行.好吧,对于作为程序员的 ...
- DEV LookUpEdit 使用方法
public class field { public string Name { get; set; } public string Explain { get; set; } } List< ...
- 使用date转换UNIX时间戳
1.将time string转换成时间戳 date -d "2010-10-12 12:25:00" +%s 2.将时间戳转换成time string date -d " ...