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
2015-01-23 14:15:54 Abhinandan Agarwal
Used optimised sieve
2012-07-19 16:11:29 (Tjandra Satria Gunawan)(曾毅昆)
Maybe you like to solve this problem: Binary Sequence of Prime Number
Enjoy! :)
2010-04-17 07:04:47 ~!(*(@*!@^&
8 must be 7.
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.