Cod sursa(job #2769352)
| Utilizator | Data | 14 august 2021 21:39:32 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
string __fname = "ciur"; 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;
}