TDPRIMES - Printing some primes

The problem statement is really simple. You are to write all primes less than 10^8

Input

There is no input.

Output

To make the problem less output related write out only the 1st, 101st, 201st, ... 1st mod 100.

Example

Input:

Output:
2
547
1229
...
99995257
99996931
99998953

Added by:Alfonso² Peterssen
Date:2010-04-06
Time limit:1.325s
Source limit:10000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ASM32 ASM64 BF CLPS LISP sbcl LISP clisp ERL HASK ICON ICK JS-RHINO LUA NEM NICE OBJC OCAML PHP PIKE PRLG-swi SCALA SCM guile SCM qobi ST SQLITE TCL WHITESPACE
Resource:Thanks to TDuke

hide comments
2010-05-21 11:22:27 sudipto das
Modular arithmatics can help to make Sieve of Eratosthenes more fast & get AC from TLE............
2010-04-17 07:05:32 যোবায়ের
Damn! I didn't know that unsigned is slow :(
2011-02-08 12:46:28 numerix
Could you please open it for Python.
Edit: Thanks for adding more languages.

Last edit: 2010-04-17 07:19:39
2010-04-17 07:05:32 jean caffou
I am testing on a very limited virtual machine...

EDIT: It really does make a lot of difference if your program is running at the same time as someone else's :)

Also uint_32 is slow, you don't have to keep a temp table of N, and #define-d functions are much faster than normal functions...

Last edit: 2010-04-12 15:49:34
2010-04-17 07:05:32 numerix
There's nothing strange about that. SPOJ uses very slow machines.
2010-04-17 07:05:32 jean caffou
My program also executes in 5secs, but I get TLE on SPOJ (time limit here is 10s) strange..
2010-04-17 07:05:32 pankaj
after lots of optimization it went to 2.8 now i don't know how to optimize more
[edit] My another code run for 2.76 in my system accepted at 9.59 here. Reduce the sizeof sieve and it will accept. Biut i really want to know how people are gotten accepted at <1sec?

Last edit: 2010-04-14 06:26:18
2010-04-17 07:05:32 pankaj
my program giving output in 2.99 sec in my sys :( TLE here
2010-04-17 07:05:32 hosam samy
the program takes 4 or 5 seconds in my PC and i got TLE :|
2010-04-17 07:05:32 :(){ :|: & };:
I used Sieve of Eratosthenes with some magic ;-)

EDIT: To all who are getting TLE,try twice before going for some more modification,due to congestion in the server sometimes it gives TLE,there were few times I resubmitted the same AC solution but I got TLE.


@Ravi:

Eratosthenes is good for this task,but not for the harder version.

Last edit: 2010-04-12 15:20:43
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.