Cod sursa(job #2417565)
| Utilizator | Data | 30 aprilie 2019 13:57:40 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.36 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n, nr;
bool p[2000005];
int main()
{
fin >> n;
for(int i = 2; i <= n; i++)
if(!p[i])
{
nr++;
for(int j = i + i; j <= n; j += i)
p[j] = 1;
}
fout << nr;
}
