One of the testcases in this code is giving error

#include<bits/stdc++.h>
using namespace std;
int main() {
unsigned long long int n;
cin>>n;
long long int p[50000001]={0};unsigned long long int p1[50000001]={0};
p[0]=0;
p[1]=0;
p[2]=1;
unsigned long long int temp=0,c=n;
for(unsigned long long int i=3;i<=90000000;i+=2){p[i]=1;}
for(unsigned long long int i=3;i<=90000000;i+=2){
if(p[i]==1){
for(unsigned long long int j=(ii);j<=90000000;j+=2i){
p[j]=0;
}
p1[temp]=i;temp++;//c–;if(c==0)break;
}
}
/for(long long int i=1;i<=5000000;i++){
if(p[i]==1){
c++;
if(c==n){cout<<i;break;}
}}
/
if(n==1)cout<<“2”;
else cout<<p1[n-2];

return 0;

please explain any loophole or possibility left in this problem!!

Hello @Ignitor,

From the next time, share your code using Online Coding Blocks IDE.
The way you have share it is introducing many syntax errors to it.
STEPS:

  1. Paste your code on: https://ide.codingblocks.com/
  2. Save your code there.
  3. Share the URL generated.

Now, coming back to your code:

You iterating the loop from i=0 to 90000000,
where i represents the index of the array p.
Error:
But you have created the array of size 50000001 only.

Modification in the size of the array is required:

Hope this would help.
Give a like if you are satisfied.

the changes that you told me to do is giving runtime error i have checked that thing already before …please see for any logical error if any you can see my code and can run for custom inputs to check it… https://ide.codingblocks.com/s/147904

if you now say that one testcase wouldnt be running for larger input then that thing is also checked by me …ive checked for the last value that a[i] can have according to the constraint given and it is giving proper output you can also check it …so please tell me only genuine problem in my code …

Hey @Ignitor,

In my previous reply, i have attached the modified code also which is running correctly for all the testcases.

I have modified your code as specified by me in my previous reply.
You can have a look on that and let me know if you don’t understand it.

sir…your code is not even getting submitted…please explain me your logic … ill modify it myself

Hello @Ignitor,

I have submitted that code thrice and it was showing correct for the test cases.

Leaving that discussion aside,
I have not written any separate logic.
I made a modification to your code:
//Modification:
long long int p[50000001]={0};unsigned long long int p1[50000001]={0};
to
long long int p[90000001]={0};unsigned long long int p1[90000001]={0};

The code is correct. There is a problem with the environment.
On submit the code, it is showing that this code has passed all the test cases(in the submission section) but displaying nothing on the submit section.

I have reported this issue.
They would soon correct it.