Cod sursa(job #190480)
Utilizator | Data | 22 mai 2008 20:19:50 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
# include <stdio.h>
# include <math.h>
long int i,n,k,j;
char a[2000010];
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;
}