PRIME1 problem in SPOj. i get a SIGSEGV error y?pls help me out
Posted
by R Karthikeyan
on Stack Overflow
See other posts from Stack Overflow
or by R Karthikeyan
Published on 2010-04-12T18:07:07Z
Indexed on
2010/04/12
18:13 UTC
Read the original article
Hit count: 314
#include<stdio.h>
main()
{
long long int m,n,i,j;
int t;
scanf("%d",&t);
while(t--)
{
scanf("%lld",&m);
scanf("%lld",&n);
long long int a[n+2];
for(i=0;i<=n;i++)
{
a[i]=1;
}
for(i=2;i<=sqrt(n);i++)
{
j=2;
while((i*j)<=n)
{
a[i*j]=0;
j++;
}
}
for(i=m;i<=n;i++)
{
if(i==1)
continue;
if(a[i]!=0)
printf("%lld\n",i);
}
}
return 0;
}
© Stack Overflow or respective owner