I am trying to solve "PRIME1"(http://www.spoj.com/problems/PRIME1/) on spoj. A lot of people are saying that I should solve it using Segmented Sieve of eratosthenes. I understood Sieve of eratosthenes but How I can implement Segmented one? I've seen all most all the resources and couldn't understand properly. This is the code I've written for Sieve of eratosthenes :
#include<stdio.h>
#include<math.h>
int main()
{
long long int i,n,j,m;
_Bool a[10000];
scanf(" %lld",&n);
for(i=2;i<=n;i++)
{
a[i]=1;
}
for(i=2;i<=sqrt(n);i++)
{
for(j=2;i*j<=n;j++)
{
a[i*j]=0;
}
}
for(i=1;i<=n;i++)
{
if(a[i]==1)
printf("%lld\n",i);
}
return 0;
}
From this, How can I implemet Segmented Sieve of eratosthenes. Please explain it in a beginner's perspective.