i am getting a run error on code submission, results for sample input are correct. i have used seive eratosthenes method to find primes.
#include<bits/stdc++.h>
#define N 10000
using namespace std;
void seivePrime(bool array[],int n)
{
array[0]=array[1]=0;
for(int i=2;ii<n;i++)
{
if(array[i]==true)
{
for(int j=ii;j<=n;j+= i)
{
array[j]=false;
}
}
}
}
int main() {
bool array[N+1];
memset(array,true,sizeof(array));
int test_case;
cin>>test_case;
if(test_case<=10000)
{
seivePrime(array,N);
while(test_case–)
{
int num;
int cost;
cin>>num;
int count=1;
for(int j=2;count<=num;j++)
{
if(array[j])
{
count++;
cost = j;
}
}
cout<<cost<<endl;
}
}
return 0;
}