Cod sursa(job #2216356)

Utilizator problem_destroyer69Daniel Hangan problem_destroyer69 Data 26 iunie 2018 14:30:11
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <bits/stdc++.h>
using namespace std;
#define int long long
char p[2000005];
int 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;
}