Cod sursa(job #2222804)
Utilizator | Data | 18 iulie 2018 01:42:30 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
using namespace std;
bitset<2000005> ciur;
int N, ans = 0;
void sieve()
{
for (int i = 3; i <= N; i += 2)
if (ciur[i] == false) {
++ans;
for (int j = 3; i * j <= N; j += 2)
ciur[i * j] = true;
}
}
int main()
{
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
fin >> N;
sieve();
fout << ans + 1;
return 0;
}