Cod sursa(job #2386063)

Utilizator oogaboogauvuvwevwevwe onyetenyevwe ugwemubwem ossas oogabooga Data 22 martie 2019 09:22:08
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.46 kb
#include <bits/stdc++.h>

using namespace std;

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

const int MX = 2000005;

bitset < MX > BS;
int N, P;

int main()
{
    in>>N;

    BS[0] = BS[1] = 1;
    for(int i = 2; i * i <= MX; ++i)
        if(BS[i] == 0)
            for(int j = i * i; j <= MX; j += i)
                BS[j] = 1;
    for(int i = 0; i <= N; ++i)
        if(BS[i] == 0)
            ++P;

    out<<P;

    return 0;
}