Cod sursa(job #498159)
Utilizator | Data | 4 noiembrie 2010 12:34:49 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.51 kb |
#include <fstream>
using namespace std;
const int DIM = 2000001;
bool c[DIM];
int n, nr;
int main() ,{
FILE *f=fopen("ciur.in","r");
FILE *g=fopen("ciur.out", "w");
int i,j;
fscanf(f,"%d", &n);
for(i = 2; i <= n; ++i)
if(!c[i])
for (j = 2 * 1;j <= n ; j += i)
c[j] = 1;
for(i = 2; i <= n; ++i)
if(!c[i])
++nr;
fprintf(g , "%d" , nr);
fclose(f);
fclose(g);
return 0;
}