Cod sursa(job #2919833)

Utilizator OvidRata Ovidiu Ovid Data 19 august 2022 23:22:45
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.75 kb
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
//#define int ll

ifstream fin("ciur.in"); ofstream fout("ciur.out");
#define cin fin
#define cout fout

int n, cnt;

bool v[2000001];


int32_t main(){
INIT

for(int i=2; i<=2000000; i++){
    if(!v[i]){
        for(int j=i*2; j<=2000000; j+=i){
            v[j]=true;
        }
    }
}
cin>>n;
cnt=n-1;
for(int i=2; i<=n; i++){
    cnt-=v[i];
}
cout<<cnt;

return 0;
}