Factorial Solved Problem code: FCTRL, factorialfctrl

Source: Internet
Author: User

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

 

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.