Factorial Solved Problem code: FCTRL, factorialfctrl
1 import sys 2 # import psyco # It is very strange that psyco is used to solve the runtime error 3 4 5 # psyco. full () 6 7 8 def z (n): # This should be a skillful algorithm 9 r = 010 while 5 <= n: 11 n/= 512 r + = n13 return r14 15 16 def main (): 17 n = int (sys. stdin. readline () 18 for t in sys. stdin: # This type of Cyclic input has no problem at all. print z (int (t) # The input is String. Remember to convert int to 20 21 main () # This function architecture is very scientific and sound
/// ANOTHER METHOD
1 for n in map (int, sys. stdin. read (). split () [1:]: 2 print z (n)
Learning
For t in sys. stdin loop input can be reused
This functional architecture is very scientific
Array preliminary understanding, the essence of the use of colons
[1:] escaped the first element (number) and then to the last element
Error
Psyco () is not always usable