Cod sursa(job #1419866)
| Utilizator | Data | 16 aprilie 2015 23:42:21 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <stdio.h>
#define NMax 2000001
#define NMax1 1000000
using namespace std;
bool V[NMax]={0};
int main()
{
freopen("ciur.in","r",stdin);
freopen("ciur.out","w",stdout);
int N,sol=0;
V[0]=V[1]=1;
for(int i=2;i<=NMax1;i++)
if(!V[i])
{
for(int j=i*2;j<=NMax-1;j=j+i)
V[j]=1;
}
scanf("%d",&N);
for(int i=2;i<=N;i++)
if(V[i]==0)
sol++;
printf("%d",sol);
}
