Cod sursa(job #2216355)

Utilizator problem_destroyer69Daniel Hangan problem_destroyer69 Data 26 iunie 2018 14:27:29
Problema Ciurul lui Eratosthenes Scor 30
Compilator cpp Status done
Runda Arhiva educationala Marime 0.35 kb
#include <bits/stdc++.h>
using namespace std;
#define int long long
int p[2000005],n,cnt;
signed main() {
    ifstream fin("ciur.in");
    ofstream fout("ciur.out");
    fin >> n;
    for (int i = 2; i <= n; i++)
    if (!p[i]){
        cnt++;
        for (int j = 2*i; j <= n; j += i)
            p[j] = 1;
    }
    fout << cnt << endl;
}