PRATEEK LOVES CANDY

WHAT’S WRONG IN THE CODE
OUTPUTS ARE COMING CORRECT BUT STILL IT’S OT PASSING ANY TESTCASE

@Prakhar_Nagpal what are the constraints in this question can you copy paste the question here?

Prateek recently graduated from college. To celebrate, he went to a candy shop and bought all the candies. The total cost was a number upto which there are n prime numbers (starting from 2). Since Prateek wants to minimize his cost, he calls you to help him find the minimum amount that needs to be paid. Being a student of Prateek bhaiya it is now your job to help him out :slight_smile: Input Format First line contains a single integer denoting the number of test cases T. Next T lines contains a single integer N, denoting the number of primes required. Constraints T <= 10000 It is guaranteed that the answer does not exceed 10^6. Output Format Print the minimum cost that needs to be paid. Sample Input 2 5 1 Sample Output 11 2 Explanation In the first case there are 5 primes upto 11(2,3,5,7,11).

@Prakhar_Nagpal constraints are quiet large , you have used brute force which is correct but for only small inputs . in this question you have to build prime sieve outside the test cases loop so that inside it you can give the answer in o(1)

bUT NONE OF THE TEST CASES ARE GETTING CORRECT

@Prakhar_Nagpal yes because all of them have very large inputs which will lead to tle

ATLEAST THE FIRST TEST CASE WAS RIGHT

NOW WHAT SHOULD I DO

bro all the testcases constraints are large your code will give tle
do you know how to build prime sieve?

No I dont know abt prime seive

which course you have taken?
is there any section with videos on number theory?

Algo++ course I have tken

@Prakhar_Nagpal wait let me provide you of a video of prateek bhaiya on prime sieve

@Prakhar_Nagpal here see this


try to understand what it is and do the question using this if then also facing issue then i will provide a commented code but you have to understand prime sieve first !

tHANKS FOR THE HELP…

anytime @Prakhar_Nagpal :smiley:

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.