Cod sursa(job #2596166)

Utilizator CharacterMeCharacter Me CharacterMe Data 9 aprilie 2020 13:03:06
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.37 kb
#include <bits/stdc++.h>

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

int n, sol;
bitset<2000005> check;

int main()
{

    fin >> n;

    for(int i = 2; i <= n; ++i){
        if(!check[i]){
            ++sol;

            for(int j = 2 * i; j <= n; j += i) check[j] = true;
        }
    }

    fout << sol;

    return 0;
}