Cod sursa(job #156156)
Utilizator | Data | 12 martie 2008 13:14:29 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<cstdio>
#define nmax 2000010
int n, v[nmax];
int main()
{
int i, j, count=0;
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
scanf("%d", &n);
for(i = 2; i <= n; i++)
if(!v[i])
{
count++;
for(j = 2*i; j <= n; j += i)
v[j] = 1;
}
printf("%d\n", count);
return 0;
}