Pagini recente » Cod sursa (job #1688529) | Cod sursa (job #2228830) | Cod sursa (job #2894850) | Cod sursa (job #1203351) | Cod sursa (job #3219058)
#include <iostream>
#include <fstream>
#include <stdint.h>
const int32_t MAX_N = 2000000;
const int32_t MAX_SIZE = (MAX_N >> 4) + 1;
uint8_t ciur[MAX_SIZE];
int main() {
std::ifstream fin("ciur.in");
std::ofstream fout("ciur.out");
int32_t n;
fin >> n;
for(int32_t i = 3, sqr = 9; sqr <= n; sqr += (i << 2) + 4, i += 2) {
int32_t ind = i >> 1;
if(ciur[ind >> 3] & (1 << (ind & 7)))
continue;
for(int32_t j = sqr; j <= n; j += i << 1) {
ind = j >> 1;
ciur[ind >> 3] |= 1 << (ind & 7);
}
}
int32_t count = 1;
for(int32_t i = 3; i <= n; ++i) {
if(!(i & 1))
continue;
int32_t ind = i >> 1;
count += !(ciur[ind >> 3] & (1 << (ind & 7)));
}
fout << count;
fin.close();
fout.close();
return 0;
}