Cod sursa(job #1145628)
Utilizator | Data | 18 martie 2014 12:42:32 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
/*
Keep It Simple!
*/
#include<stdio.h>
#include<list>
using namespace std;
#define MaxN 2000005
bool Era[MaxN];
int N,Prime;
int main()
{
freopen("ciur.in","r",stdin);
freopen("ciur.out","w",stdout);
scanf("%d",&N);
Prime = 1;
for(int i=3; i<=N; i+=2)
{
if(!Era[i])
{
Prime++;
for(int j=i; j<=N; j+=i)
Era[j] = 1;
}
}
printf("%d",Prime);
}