Cod sursa(job #2216354)

Utilizator problem_destroyer69Daniel Hangan problem_destroyer69 Data 26 iunie 2018 14:25:49
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.39 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++;
        int j = 2*i;
        while (j+i <= n){
            p[j] = 1;
            j += i;
        }
    }
    fout << cnt << endl;
}