Cod sursa(job #1913238)
Utilizator | Data | 8 martie 2017 12:17:18 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
const int NMax = 2000005;
int n,NR;
bool p[NMax];
int main()
{
f >> n;
for(int i = 3; i < n; i += 2){
if(p[i] == 0){
NR++;
for(int j = i + i; j < n; j += i){
p[j] = 1;
}
}
}
if(n >= 2)
NR++;
g << NR << '\n';
return 0;
}