Cod sursa(job #2722501)

Utilizator KPP17Popescu Paul KPP17 Data 12 martie 2021 21:45:18
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.31 kb
#include <fstream>
#define mF "ciur"
std::ifstream in(mF ".in");
std::ofstream out(mF ".out");
#include <bitset>
std::bitset<2000001> V;
int main()
{
    int n, s = 0; in >> n; for (int i = 2; i<<1 <= n; i++) if (!V[i]) for (int j = i<<1; j <= n; j += i) s += !V[j], V[j] = true;
    out << n - 1 - s;
}