Hello Buddy,
I tried to solve the question and as per sample input and i got same output also but i am facing issue please look in to my code and help me
Ref :
Prateek Loves Candy
@s.v,
You are supposed to use the prime seive optimisation technique (sieve of eratosthenes). Also make sure that you execute the primeseive function that you will make before the test cases only to prevent TLE.
Precompute the prime numbers using sieve technique.
In the sieve technique where you create a boolean array of b+1 size.
And start from the first prime number i.e. 2. Take its square(4) and increment it by the number you took (i.e. 4,6,8,10 and so on). Mark all these as false since they cannot be primes.
Now take the next unmarked number, 3. And mark 9,12,15 and so as false. Similarly do it for 4. 16,20,24 and so on as false.
but its not working please look in to my code
@s.v,
https://ide.codingblocks.com/s/328265 corrected code
Use SieveOfEratosthenes(); outside the for loop. In your code, everytime the for loop is executed, you will be calculating prime numbers which causes a TLE.
Just put it outside the for-loop and it will work correctly. 