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
kalinga:
2022-08-13 11:18:48
what java code will use? tried all attempt getting TLE/Sigterm
|
|
sdgik:
2022-04-12 09:46:47
If you are using java, dont use a dynamic array to store a list of primes, just create a static one of 5000000 size it will pass, I got 1.19s. using a dynamic array you will get TLE. |
|
rony003:
2022-01-21 12:09:43
use bool not int
|
|
chirag8011:
2022-01-07 09:39:27
How did we came to know that 90000000 will work, I mean how did we find it? |
|
shahid_92:
2021-12-06 08:41:56
getting TLE , use bool instead of int :) |
|
coding_geek1:
2021-09-23 19:12:26
Those who are still getting TLE using the below mentioned constraints try using fastio |
|
mdminhaz:
2021-08-06 20:38:35
bool is_prime[90000001];
|
|
vikassnwl:
2021-08-01 19:38:38
n = 86028121
|
|
toocurious:
2021-08-01 18:12:04
For those who are getting TLE with c++. Try using bool array instead of int array in sieve. |
|
akshat_19:
2021-05-14 11:42:41
Codechef compiler showed 1.76 sec on given test cases yet I got AC. |
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 |