Pagini recente » Cod sursa (job #2541053) | Cod sursa (job #372504) | Cod sursa (job #1553208) | Cod sursa (job #1749834) | Cod sursa (job #2217483)
/**
* Worg
*/
#include <bitset>
#include <cstdio>
FILE *fin = freopen("ciur.in", "r", stdin); FILE *fout = freopen("ciur.out", "w", stdout);
const int MAX_N = 2e6 + 5;
/*-------- Data --------*/
int n;
std::bitset<MAX_N > v;
/*-------- --------*/
int ErathostenesSieve() {
for(int i = 3; i * i <= n; i += 2) {
if(!v[i]) {
for(int j = i * i; j <= n; j += 2 * i) {
v[j] = 1;
}
}
}
int countPrime = 1;
for(int i = 3; i <= n; i += 2) {
countPrime += (v[i] == 0);
}
return countPrime;
}
int main() {
scanf("%d", &n);
printf("%d\n", ErathostenesSieve());
return 0;
}