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

hide comments
acktron: 2020-06-23 09:50:14

Solved in one go....
using bool array in c++.

dishantsheth: 2020-06-17 18:08:57

In Java, any implementation other than a bit-wise sieve will give you a TLE.

dv_kil: 2020-06-13 11:52:14

How can I implement this using python?

hasib_ullah: 2020-06-07 09:56:54

Even using bitset didn't pass the time limit in java :(

krishp: 2020-06-01 21:13:15

.64 sec PYTHON3

Last edit: 2020-06-01 21:22:34
krishp: 2020-06-01 20:56:07

Run sieve up to 86028121. 86028122 is last prime number it will check for.

Last edit: 2020-06-01 21:22:56
abhi1999: 2020-05-02 17:54:20

Not getting ac in java and submitted the same logic in c++ and got ac

abhi1999: 2020-05-01 14:33:51

anyone submited it in java

sourav_cse19: 2020-05-01 13:21:28

why wrong!

abhinandan824: 2020-04-25 10:30:15

@sanket17
how did you came with that number 87 million?


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