Pagini recente » Cod sursa (job #1714991) | Cod sursa (job #3839) | Rating dementorr (dementorrr) | Teoria jocurilor | Cod sursa (job #1008661)
#include <cstdio>
#include <bitset>
using namespace std;
bitset<1000010> e;
int main() {
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
int n;
scanf("%d", &n);
for (int i = 3; i * i < n; i += 2) {
if (e[i >> 1]) {
continue;
}
for (int j = i * i; j <= n; j += (i << 1)) {
e[j >> 1] = true;
}
}
int res = 1;
for (int i = 3; i <= n; i += 2) {
if (!e[i >> 1]) {
++res;
}
}
printf("%d\n", res);
return 0;
}