Cod sursa(job #523924)

Utilizator scutaru.georgianGeorgian scutaru.georgian Data 19 ianuarie 2011 20:25:19
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.25 kb
#include<fstream.h>
ifstream f("ciur.in");ofstream g("ciur.out");
int x,i,j,np;
char prim[2000001];
int main()
{f>>x;
 for(i=2;i<=x;i++) 
	if(!prim[i])
		{
		 np++;
		 for(j=i+i;j<=x;j+=i) prim[j]=1;
		 }
g<<np;	
g.close();
return 0;	
}