Pagini recente » Monitorul de evaluare | Rating astrid grun (astridg) | Cod sursa (job #3150861) | Monitorul de evaluare | Cod sursa (job #151121)
Cod sursa(job #151121)
#include<fstream.h>
#define dim 2000001
#define dim2 1003
char prim[dim];
unsigned long cont,n,a[dim2],cont2;
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{unsigned long i,j;
f>>n;
f.close();
for(i=2;i<=n;i++)
if(!prim[i])
{cont2++;
for(j=i+i;j<=n;j+=i)
prim[j]=1;
}
for(i=n;i>=2;i--)
if((!prim[i])&&(cont<dim2))
a[++cont]=i;
g<<cont2<<'\n';
cont2=1;
for(i=cont;(i>=1)&&(cont2<=1000);i--) {g<<a[i]<<" ";cont2++;}
g<<'\n';
g.close();
return 0;
}