Cod sursa(job #1343293)
Utilizator | Data | 15 februarie 2015 10:41:19 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include <fstream>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
bool c[2000001];
int main() {
int n, contor = 0;
in >> n;
for(int i = 2; i * i <= n; i++)
if(!c[i])
for(int j = i * i; j <= n; j += i)
c[j] = 1;
for(int i = 2; i <= n; i++)
if(!c[i])
contor++;
out << contor;
return 0;
}