Cod sursa(job #2366001)

Utilizator qwerty1234qwerty qwerty1234 Data 4 martie 2019 17:55:59
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.4 kb

#include <bits/stdc++.h>


using namespace std;

ifstream fin ("ciur.in");
ofstream fout ("ciur.out");


int n;

bitset < 2000005 > viz;

int main()
{
    fin >> n;
    for(int i = 2 ; i <= n ; i++)
        if(!viz[i])
            for(int j = 2 * i ; j <= n ; j += 2 * i)
                viz[j] = 1;
    fout << viz.count() << "\n";
    fin.close();
    fout.close();
    return 0;
}