Cod sursa(job #153477)
Utilizator | Data | 10 martie 2008 16:05:54 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.38 kb |
#include <stdio.h>
#define nmax 2000008
char p[nmax];
int i, n, j, h;
int main()
{
freopen("ciur.in", "rt", stdin);
freopen("ciur.out", "wt", stdout);
scanf("%i", &n);
for (i = 1; i <= n; ++i)
p[i] = 1;
for (i = 2; i <= n; ++i)
if (p[i])
{
++h;
for (j = i + i; j <= n; j += i)
p[j] = 0;
}
printf("%i\n", h);
}