Cod sursa(job #1012833)

Utilizator CostinVFMI CostinVictorGabriel CostinV Data 19 octombrie 2013 18:21:20
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.38 kb
#include<iostream>
#include<fstream>

using namespace std;



int main()
{
    long nr=0, i, n, v[2000000];
    ifstream f("ciur.in");
    ofstream g("ciur.out");

    f>>n;

    for(i=2; i<=n; i++)
    {
        if (!v[i])
        {
            for(int j=i+i; j<=n; j+=i)
                v[j]=1;
            nr++;
        }

    }

    g<<nr;

    return 0;
}