Hi,
the last time I struggled with TLE submitting python code at spoj, i got the advice to analyze the performance of my code by profiling. I succeeded with it...
...
Another point which may be time consuming (but I didn't check): The input values may be quite large (10**30), so the product will be huge, too. Is it really necessary to use your scaling factors in this case or can this be optimized? But I didn't investigate this yet.
Cheers
Daft
Edit: details removed