Cod sursa(job #633732)

Utilizator WuximUrsinschi Eduard Wuxim Data 14 noiembrie 2011 17:46:00
Problema Ciurul lui Eratosthenes Scor 60
Compilator cpp Status done
Runda Arhiva educationala Marime 0.33 kb
#include <fstream>

using namespace std;

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

char v[2000001];
long x,nr,k,n;
int main()
{  f>>n;
   nr=0;
   for(x=2;x<=n;x++)
      if(v[x]==0){ nr++;
                   for(k=2*x;k<=n;k=k+x)v[k]=1;
                 }
  g<<nr<<'\n';
  f.close();g.close();
  return 0;
}