Cod sursa(job #778004)

Utilizator ionut_blesneagIonut Blesneag ionut_blesneag Data 13 august 2012 19:31:42
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.29 kb
#include<fstream>
using namespace std;

ifstream f("ciur.in");
ofstream g("ciur.out");

bool viz[2000001];
int nrp,n,i,j;

int main()
{f>>n;
j=1;

while(j<n)
{j++;
if(!viz[j])
{nrp++; 
 for(i=j; i<=n; i+=j)
  viz[i]=true;}
}
g<<nrp;          
f.close();
g.close();
return 0;}