TDKPRIME - Finding the Kth Prime

The problem statement is really simple. There are some queries. You are to give the answers.

Input

An integer stating the number of queries Q (equal to 50000), and Q lines follow, each containing one integer K between 1 and 5000000 inclusive.

Output

Q lines with the answer of each query: the Kth prime number.

Example

Input:
7
1
10
100
1000
10000
100000
1000000

Output:
2
29
541
7919
104729
1299709
15485863

Added by:Alfonso² Peterssen
Date:2010-04-06
Time limit:1.240s
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
2016-04-05 19:12:44
lolypop question
2015-09-03 12:32:42 Sriharshaa Sammeta
can u please give explanation or some sort of idea about bitwise sieve ?
2015-07-18 18:07:12 SangKuan
in debug mode i use 2~3 second,but only use 0.77s in spoj,haha
2015-07-06 22:29:28 :.Mohib.:
Nice One :)

Last edit: 2015-07-06 22:30:54
2015-06-24 09:42:10 V Y
Superb 'solution'. We don't have a formula. We don't need primality tests. What are we left with? Optimize 'space'. It will be enough but not optimal.

Last edit: 2015-06-24 09:45:01
2015-06-20 10:22:50 [Mayank Pratap]
Optimised Sieve leads to AC :) Superb Problem...
2015-06-06 14:51:56 Ankit Sultana
Awesome Problem!!
2015-06-04 21:41:49 Nitesh Tripathi
Learned a lot from this problem :)
2015-05-25 08:09:27 i_am_looser
bit-wise optimized sieve...... AC ;)
2015-04-27 21:48:48 karan
one of my favourite question <3
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.