Prime generator

My Test Case is passed but in this question n and m can go upto 1000000000,
and in my code If i am replacing 10000001 with 1000000001,it is showing Memory Error
My code https://ide.codingblocks.com/s/187059
This code passed here but same question in SPOJ causing runtime error there due to the same.
help!!!

Yes because 1000000001 space cannot be allocated because it requires very big memory size, which can’t be allocated due to memory overflow. You have to optimize space complexity here as well. Moreover time and space constraints are of prime importance in spoj questions.

Hope this cleared your doubt. :blush:

Plz tell me how to optimize space @S18CRX0120

You can use segmented sieve, or change the approach. You should search online blogs for this.

Hope this cleared your doubt. :blush:

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.