Primes... again
Given two integers N and M (N ≤ M), output all the prime numbers between N and M inclusive, one per line.N and M will be positive integers less than or equal to 1,000,000,000.
The difference between N and M will be less than or equal to 5,000,000.
Sample Input
5 20
Sample Output
5 7 11 13 17 19
All Submissions
Best Solutions
Point Value: 15 (partial)
Time Limit: 5.00s
Memory Limit: 32M
Added: Oct 18, 2008
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
Am I missing something?
I'm using trial division up to half of the number
However, I've noticed that the memory limit was actually too strict to be solved in Python, which uses references instead of true 1-byte booleans. I also don't think it's fair to force Python users to do some bit hackery just to solve this problem. I've therefore bumped to memory limit from 16M to 32M and confirmed that it's doable.
I don't know enough about Python to give a reasonable explanation as to why you MLE; as for why you TLE, it's likely just because of Python's slow I/O.
Consider trying to solve this in another language.
Congratulations nonetheless on doing this problem in Python.
OK instead of AC is a relic of days past.