Pagini recente » Cod sursa (job #411058) | Cod sursa (job #3236407) | Cod sursa (job #3324533) | Cod sursa (job #346318) | Cod sursa (job #3313205)
#include <iostream>
#include <fstream>
#include <stdint.h>
const int32_t MAX_N = 2000000;
bool primes[MAX_N + 1];
int main() {
std::ifstream fin("ciur.in");
std::ofstream fout("ciur.out");
int32_t n;
fin >> n;
for(int32_t i = 2; i <= n; ++i)
primes[i] = true;
for(int32_t i = 2; i <= n; ++i) {
if(!primes[i])
continue;
for(int32_t j = i << 1; j <= n; j += i)
primes[j] = false;
}
int32_t count = 0;
for(int32_t i = 2; i <= n; ++i)
count += (int32_t)primes[i];
fout << count;
fin.close();
fout.close();
return 0;
}