In the question , prateek loves candy, I used prime sieve but it shows run time error for n=10^6 and if I use for 1000 then it works fine but my test case does not pass
how to resolve this issue?
Why it 's showing run time error?
hey @LPLC0114, max value of N is 10^6, for which you are using int datatype, but range of int is not upto this number. Thatswhy it is giving correct answer for small number like 1000 but not for large range. Change all int to long long int except for array p as you make it dynamic.
I have made change to your code you can check them here https://ide.codingblocks.com/s/106907
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.