Cod sursa(job #2410037)
| Utilizator | Data | 19 aprilie 2019 17:45:43 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifdef BLAT
freopen("input", "r", stdin);
#else
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n;
cin >> n;
vector< bool > prim(n + 1);
int ans = 1;
for(int i = 3; i <= n; i += 2) {
if(!prim[i]) {
++ans;
for(long long j = 1ll*i*i; j <= n; j += 2*i) {
prim[j] = true;
}
}
}
cout << ans << '\n';
return 0;
}
