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 ...
随机推荐
- cygwin编译SDL1.2
1.下载了一个SDL-1.2.14.tar.gz 2.下载一个cygwin64对SDL-1.2.14.tar.gz解压 tar -zxvf SDL-1.2.14.tar.gz 在网上找的大概是需要需要 ...
- Ubuntu 下安装使用文件比较合并图形工具Meld
Meld是一款跨平台的文件比较合并工具使用Python开发,具体内容参照官网:http://meldmerge.org/ 注意以下环境要求: Requirements Python 2.7 (Pyth ...
- Ext中窗体第二次点击报错或者其内控件不显示的问题,弄了2天才解决,记录下
registerPanel.js: registerPanel = new Ext.form.FormPanel({ id:'registerPanel', layout:'form', autoHe ...
- Windows系统结构
四种用户模式进程:1.系统支持进程,比如登录进程和会话管理器,并不是Windows服务,不有服务控制管理器启动2.服务进程,一些以Windows服务方式来运行的组件3.用户应用进程4.环境子系统服务器 ...
- IOS uitableviewcell 向左滑动删除编辑等
主要实现这个方法就好了 -(NSArray<UITableViewRowAction *> *)tableView:(UITableView *)tableView editActions ...
- C# 酒鬼买酒喝,瓶盖和空瓶子可以换新的酒
using System; using System.Collections.Generic; using System.Linq; using System.Text; using Syst ...
- Python字典的操作与使用
字典的描述 字典是一种key-value的数据类型,使用就像我们上学用的字典,通过拼音(key)来查对应字的详细内容(value). 字典的特性 1.字典是无序的(不像列表一样有下标,它通过key来获 ...
- Java开源报表Jasper入门(2) -- 使用JasperSoft Studio创建一个简单报表
在接下来的教程中,我们将实现一个简单的JasperReports示例,展现其基本的开发.使用流程.文章很长,不过是以图片居多,文字并不多. 实例中使用最新的Jasper Studio5.2进行报表设计 ...
- 下载配置MySql,高速启动MySql批处理,MySQLclient软件SQL-Front的配置---ShinePans
首先,下载 sql 绿色版,: http://yunpan.cn/cgERHhTtV8XGh 提取码 85bc 然后解压就可以用, 安装文件夹下有bin文件夹,从里面的命令中启动服务 例如以下: ...
- oracle 同样数据删除(仅仅留一条)
DELETE FROM reg_user t1 WHERE user_name='9527008' and rowid > ( SELECT min(rowid) FROM location t ...