Cod sursa(job #2164963)
Utilizator | Data | 13 martie 2018 10:36:07 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.28 kb |
#include <iostream>
#include <fstream>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
int ciur[2000001],n,i,nr,d;
int main()
{f>>n;
for(i=2;i<=n;i++)
{if(ciur[i]==0)
{nr++;
for(d=2*i;d<=n;d=d+i)
{ciur[d]=1;}
}
}
g<<nr;
return 0;
}