Cod sursa(job #2224824)
Utilizator | Data | 25 iulie 2018 11:51:36 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <iostream>
#include <fstream>
using namespace std;
const int MAXN = 2000005;
bool ciur[MAXN];
int val[MAXN];
int main()
{
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n;
fin >> n;
int len = 0;
for(int i = 2; i <= n; i++){
if(!ciur[i]){
val[++len] = i;
for(int j = i + i; j <= n; j += i)
ciur[j] = 1;
}
}
fout << len;
return 0;
}