I work only with Python3,
I think there are few (4 or 5) real* Python3 solutions for FCTRL, but it seems there are some.
(* Now, thanks numerix, I know that there were the Python2.6-psyco-->>Python3.1 "bug")
I have a correct function, and imho quite efficient, but I always got TLE.
So I tested speed on my machine with this : (not a spoil)
testString=str(5**11-5)+"\n" # 9 digits. ;-)
from time import time
st=time()
import sys
for n in range(10**5):
sys.stdout.write(testString)
sys.stdout.flush()
print(time()-st)
It's 1.9s on my machine, so I can easily imagine TLE on SPOJ. (about ×30? slower)
How is it possible to do FCTRL in python3 knowing that ???
Worse, I can't understand how I solved PRIME1 (more to compute and print !!!) in less a second.
But it seems sven recently did it in 2.55s on spoj in pure python3, isn't it ?
After that, I make a sample size=10⁵ in population(1--10⁹), and test my function:
from random import *
entree = list(map(str, sample(range(1, 10**9), 10**5)))
def Z(n):
" n is a string"
# (...) would be a spoil
return result
from time import time
st=time()
import sys
#_ = sys.stdin.readline()
#for n in sys.stdin:
for n in entree:
sys.stdout.write(Z(n))
print(time()-st)
My simulation is done in 2.2s, quite good for me.
So I think the problem is in my read/write on I/O,
is it true or is there an other reason ?
Many thanks.