Cod sursa(job #190479)
Utilizator | Data | 22 mai 2008 20:19:15 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
# include <stdio.h>
# include <math.h>
long int i,n,k,j;
int a[700010];
int main ()
{
freopen ("ciur.in","r",stdin);
freopen ("ciur.out","w",stdout);
scanf ("%li",&n);
for (i=1;i<=n;i++)
a[i]=0;
for (i=2;i<=n;i++)
if (a[i]==0)
{
k++;
for (j=i;j<=n;j=j+i)
a[j]=1;
}
printf ("%li",k);
return 0;
}