Cod sursa(job #2566099)
| Utilizator | Data | 2 martie 2020 18:48:38 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.44 kb |
#include <bits/stdc++.h>
#define MAXN 2000005
#define INF 2e9
#define FILENAME std::string("ciur")
std::ifstream input (FILENAME+".in");
std::ofstream output(FILENAME+".out");
int N;
bool ers[MAXN];
int main()
{
input >> N;
int cnt = 0;
for (int i=2; i<=N; ++i) if (!ers[i]) {
++ cnt;
for (int j=2*i; j<=N; j+=i)
ers[j] = true;
} output << cnt << '\n';
return 0;
}
