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 ...
随机推荐
- MyGeneration 默认设置中没有数据库驱动
这 个问题的出现基本上是因为MyGeneration 1.3需要的是 .Net framework 4.0,如果系统安装了 .Net 2.0的版本,安装程序执行的 regasm.exe为2.0版本下的 ...
- Spark学习笔记--Transformation 和 action
转自:http://my.oschina.net/hanzhankang/blog/200275 附:各种操作的逻辑执行图 https://github.com/JerryLead/SparkInte ...
- Java学习笔记--通过java.net.URLConnection发送HTTP请求
http://www.cnblogs.com/nick-huang/p/3859353.html 使用Java API发送 get请求或post请求的步骤: 1. 通过统一资源定位器(java.net ...
- hdu 相遇周期
#include <cstdio> #include <cstring> #include <algorithm> using namespace std; int ...
- 负重前行的婚纱线上路 - i天下网商-最具深度的电商知识媒体
负重前行的婚纱线上路 - i天下网商-最具深度的电商知识媒体 负重前行的婚纱线上路
- Windows系统结构
四种用户模式进程:1.系统支持进程,比如登录进程和会话管理器,并不是Windows服务,不有服务控制管理器启动2.服务进程,一些以Windows服务方式来运行的组件3.用户应用进程4.环境子系统服务器 ...
- (转)iOS Wow体验 - 第四章 - 为应用的上下文环境而设计
本文是<iOS Wow Factor:Apps and UX Design Techniques for iPhone and iPad>第四章译文精选,其余章节将陆续放出.上一篇:Wow ...
- swing入门例子
// a simple exmple that can show the basis of swing------------------------------------------------- ...
- DOM事件处理程序-事件对象-键盘事件
事件流: 事件流--描述的是从页面中接受事件的顺序 IE ---事件冒泡流:即事件最开始由最具体的元素(文档中嵌套层次最深的那个节点)接收,然后逐级向上传播至最不具体的那个节点(文档). Netsc ...
- (转)IIS5.1的安装配置并发布ASP.NET网站
最近跟老师做一个桥梁养护系统的项目,要求用VS2008+Sql Server2000,服务器用IIS.由于之前做过的ASP.NET项目都是用的VS内置的服务器,并没有使用过IIS,第一次搭,花了几个小 ...