Cod sursa(job #555648)
| Utilizator | Data | 15 martie 2011 17:39:56 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.42 kb |
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
long long n , cont;
bool x[2000005];
int main ()
{
ifstream f ("ciur.in");
ofstream g ("ciur.out");
f >> n;
x[1] = 1;
for (int i = 2 ; i <= n ; ++i)
if (!x[i])
for (int j = i + i ; j <= n ; j += i)
x[j] = 1;
for (int i = 1 ; i <= n ; ++i)
if (!x[i])
cont++;
g << cont;
return 0;
}
