Cod sursa(job #2769351)
Utilizator | Goreanu Victor victorgoreanu | Data | 14 august 2021 21:38:29 |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
string __fname = "cautbin"; ifstream in (__fname + ".in"); ofstream out (__fname + ".out");
#define cin in
#define cout out
int main(){
int n;
cin >> n;
vector <bool> a (n + 2);
for (int i = 2; i < n; i++){
if (a[i] == false){
for (int j = i + i; j < n; j += i){
a[j] = true;
}
}
}
int k = 0;
for (int i = 2; i < n; i++){
if (a[i] == false) k++;
}
cout << k;
return 0;
}