Cod sursa(job #1848851)

Utilizator andrei1299Ghiorghe Andrei Alexandru andrei1299 Data 16 ianuarie 2017 19:09:43
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.43 kb
#include <iostream>
#include <math.h>
#include <fstream>

using namespace std;
int n,p[2000005],cnt;

int main()
{

    ifstream fin("ciur.in");
    fin>>n;
    fin.close();
    for(int i=2;i<=n;i++)
    {
        if(p[i]==0)
        {
            cnt++;
            for(int j=i;j<=n;j+=i)
                p[j]=1;
        }
    }
    ofstream fout("ciur.out");
    fout<<cnt;
    fout.close();
    return 0;
}