Hi I'm getting SIGSEGV error for this problem, dont know where is th problem: http://www.spoj.com/problems/PRIME1/ I tried to solve it by sieve-of-Eratosthenes algo given on Wikipedia. here is my code, please help thanks in advance.
int main()
{
int t; // test cases
cin>>t;
while(t--)
{
long int m,n;
cin>>m>>n;
if( 1 <= m <= n <= 1000000000 && n-m<=100000)
{
bool a[n];
for(long int i=2;i<=n;i++)
{
a[i]=true; // set all to true
}
a[0]=false;
a[1]=false;
for( long int i=2;i*i<=n;i++)
{
if(a[i])
{
for( long int k=i*i;k<=n;k+=i)
{
a[k]=false;
}
}
}
for(long int i=m;i<=n;i++)
{
if(a[i])
cout<<i<<endl; //Now all i such that a[i] is true are prime.
}
cout<<endl;
}
else
return -1;
}
return 0;
}