Cod sursa(job #3240396)

Utilizator prares06Papacioc Rares-Ioan prares06 Data 14 august 2024 17:04:23
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.41 kb
#include<bits/stdc++.h>
using namespace std;

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

int n, cnt;
bitset<2000001> c;

int main(){
    fin >> n;

    c[0] = c[1] = true;

    for(int i = 2; i * i <= n; ++i)
        if(!c[i])
            for(int j = i * i; j <= n; j += i)
                c[j] = true;

    for(int i = 3; i <= n; i += 2)
        cnt += !c[i];

    fout << cnt + 1;
}