Cod sursa(job #2569150)
Utilizator | Data | 4 martie 2020 11:17:37 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 50 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
int n, i, j, k, v[2000001], c;
int main()
{
fin >> n;
for (i = 2; i <= n; i++)
{
if(v[i] == 0)
{
c++;
for (j = i * 2; j <= n; j += i)
v[j] = 1;
}
}
fout << c;
return 0;
}