Pagini recente » Cod sursa (job #283600) | Cod sursa (job #10048) | Cod sursa (job #2441279) | Cod sursa (job #2909940) | Cod sursa (job #152816)
Cod sursa(job #152816)
#include<stdio.h>
#define nmax 2000000
long long int i,j,k,n;
char v[nmax];
int main()
{
freopen("ciur.in","r",stdin);
freopen("ciur.out","w",stdout);
scanf("%lld",&n);
v[1]=-1;
for(i=2;i<=n/2+1;i++)
for(j=2;i!=-1 && j*i<=n;j++)
v[i*j]=-1;
long long inceput=1;
for(i=n;i>0;i--)
if(v[i]==0)
{
k++;
if(k<=1000)
inceput=i;
}
printf("%lld\n",k);
for(i=inceput;i<=n;i++)
if(v[i]==0)
printf("%lld ",i);
return 0;
}