Cod sursa(job #900685)

Utilizator pulseOvidiu Giorgi pulse Data 28 februarie 2013 21:13:36
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.45 kb
#include<fstream>
#define nmax 2000005
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");

int count,n,prim[nmax],v[nmax/3];

void ciur()
{
    int i,j;
    count=0;
    for(i=2; i<=n; ++i)
    prim[i]=1;
    for(i=2; i<=n; ++i)
    if(prim[i])
    {
        ++count;
        for(j=i+i; j<=n; j+=i)
        prim[j]=0;
    }
    g<<count;
}

int main()
{
    f>>n;
    ciur();
    f.close();g.close();
    return 0;
}