Cod sursa(job #412423)
Utilizator | Data | 5 martie 2010 17:01:29 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.35 kb |
//Ciurul lui Eratostene
#include<fstream.h>
ifstream f("ciur.in");
ofstream g("ciur.out");
long x,n,y,v[2000001],s;
int main()
{
f>>n;
s=0;
for(x=2;x<=n;x++)
{ if(v[x]==0)
y=2;
while (y*x<=n)
{v[y*x]=1;
y++;}
}
for(x=1;x<=n;x++)
if (!v[x])
s++;
g<<s-1<<'\n';
f.close();
g.close();
return 0;
}