Pagini recente » Cod sursa (job #3323868) | Cod sursa (job #3238346) | Cod sursa (job #926595) | Cod sursa (job #1673686) | Cod sursa (job #3312703)
#include <bits/stdc++.h>
using namespace std;
int main() {
#ifndef LOCAL
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
#endif
ios::sync_with_stdio(false);
cin.tie(nullptr);
int N;
cin >> N;
vector<bool> P((N >> 1) + 1);
for (int p = 1; ((p * p) << 1) + (p << 1) <= N; ++p) {
if (!P[p]) {
for (int q = ((p * p) << 1) + (p << 1); (q << 1) + 1 <= N;
q += (p << 1) + 1) {
P[q] = 1;
}
}
}
int M = 1;
for (int i = 1; (i << 1) + 1 <= N; ++i) {
if (!P[i]) {
++M;
}
}
cout << M << "\n";
return 0;
}