Cod sursa(job #2608175)

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

int main() {
    int n, i, j, rez = 0;
    bool v[2000005];
    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);
}