PRIMES2  Printing some primes (Hard)
The problem statement is really simple (the constraints maybe not). You are to write all primes less than 10^9.
Input
There is not input.
Output
To make the problem less output related write out only the 1st, 501st, 1001st, ... 1st mod 500.
Example
Input: Output: 2 3581 7927 ... 999978527 999988747 999999151
hide comments
Michael Kharitonov:
20180102 20:21:47
@Howard Roark: you need to output every 500th prime number, about 100,000 total


Howard Roark:
20171230 16:39:39
This will be a real challenge on Java. All the optimizations will be needed just to get to computation of the list of primes to come in under the time limit, and that's not even counting the time needed for the I/O. The I/O will also require optimizations to reduce the cost of converting all those integers (about 50 million) to base 10 strings.


VISHAL DEEPAK AWATHARE:
20150224 10:24:01
in hints on to get the crazy speed? 

Krishna Mohan:
20141228 17:16:19
My code is spending all the time trying to output the numbers, if I just comment out the printf statements, It is taking a little over 3s to run, but with the io it is going to about 14s, is there a faster way to print?

Added by:  Alfonso2 Peterssen 
Date:  20100409 
Time limit:  2.281s 
Source limit:  50000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  C CPP C++ 4.3.2 JAVA PASGPC PASFPC 
Resource:  Thanks to TDuke 