#include
#include <math.h>
using namespace std;
int main() {
int t,i;
long m,n,current,rootn,marker,markeris;
scanf("%d\n",&t);
while(t--)
{
scanf("%ld %ld",&m,&n);
rootn=ceil((float)sqrt(n));
rootn++;
bool prime[rootn+1];
bool isprime[n-m+2];
for(i=0;i<rootn+1;i++) prime[i]=true;
for(i=0;i<n-m+2;i++) isprime[i]=true;
current=2;
while(current<=rootn)
{
marker=2;
while(current*marker<=rootn)
{
prime[current*marker]=false;
marker++;
}
markeris=ceil((float)m/current);
if(markeris<2) markeris=2;
while(current*markeris<=n)
{
isprime[current*markeris-m]=false;
markeris++;
}
current++;
while(current<=rootn && !prime[current]) current++;
}
for(i=0;i<=n-m;i++) if(isprime[i] && i+m>1) printf("%ld\n",i+m);
if(t) printf("\n");
}
return 0;
}
This is my code. Although it is giving the write answer in ideone but it show wrong answer here. What could be the problem?