Cod sursa(job #2608164)

Utilizator matthriscuMatt . matthriscu Data 30 aprilie 2020 18:38:24
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.35 kb
#include <cstdio>

bool v[2000005];

int main() {
    int n, i, j, rez = 0;
    freopen("ciur.in", "r", stdin);
    freopen("ciur.out", "w", stdout);
    scanf("%d", &n);
    for(i = 2; i <= n; ++i)
        if(v[i] == 0) {
            ++rez;
            for(j = i*i; j <= n; j += i)
                v[j] = 1;
        }
    printf("%d ", rez);
}