TLE and run time error in FCTRL problem

Sir/Mam
here is my code in python 3.1.2 to find the number of trailing zeroes in the factorial of a number

max=(int)(input())
for i in range(max):
    sum=0
    n=(int)(input())
    while n!=0:
       sum=sum+(int)(n/5)
       n=n/5
    print(sum)

first i got a TLE error then I wrote
import psyco
psyco.full()
which i saw in one of the discussions.
Then i started gettting the nzec error…please help…

One of the first things i would suggest is not to use psyco. I have tried using it a number of times but it always gives NZEC. I guess it has to do with the internal working of the library.

Now coming to your code, there is nothing wrong with it. Python 3.1 is just too slow and the relaxed time limit is not sufficient for it. You should switch to using 2.7 here. Judging by your submissions list, yi guess you already have!

1 Like