Cod sursa(job #2487379)

Utilizator MariusblockMoga Marius-Ioan Mariusblock Data 4 noiembrie 2019 17:41:26
Problema Ciurul lui Eratosthenes Scor 50
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.49 kb
#include <bits/stdc++.h>
#define MOD 1999999973
#define ull unsigned long long

using namespace std;

ifstream fin("ciur.in");
ofstream fout("ciur.out");

int v[2000005];

int main()
{
    int n,i,j;
    int c = 0;
    fin>>n;
    for(i = 2; i <= n; i++){
        if(v[i] == 0){
            for(j = 2*i; j <= n; j+=i){
                v[j] = 1;
            }
        }
    }
    for(i = 2; i <= n; i++){
        if(!v[i]) c++;
    }
    fout<<c<<'\n';
    return 0;
}