Kindly help to solve this problem using python…https://www.spoj.com/problems/TDKPRIME/
It might be possible that with given constraints, this problem is unsolvable in python
but you can try like first using sieve find the prime numbers up to 8 * 10**7
then using dictionary just print the kth prime no.
Thanks bro…
Although this problem cann’t be solved in given time constraint, but here I am writing the best solution I can be write.
from math import sqrt
from sys import stdin,stdout
isPrime = [True]*(87000008)
isPrime[1] = False
for i in range(2,int(sqrt(87000008))):
if isPrime[i]:
for j in range(i*2,87000008,i):
isPrime[j] = False
primeList = []
for i in range(len(isPrime)):
if isPrime[i]:
primeList.append(i)
for _ in range(int(stdin.readline())):
n = int(stdin.readline())
print(primeList[n])