Cod sursa(job #1654352)
Utilizator | Data | 16 martie 2016 23:02:18 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.36 kb |
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
unsigned int v[2000005];
int main()
{
int n,cont=0,i,j;
fin>>n;
for(i=2;i<=n;i++)
v[i]=1;
for(i=2;i<=n;i++)
{
if(v[i]==1){
++cont;
for(j=2*i;j<=n;j+=i)
v[j]=0;
}
}
fout<<cont;
return 0;
}