Cod sursa(job #2058185)
Utilizator | Data | 5 noiembrie 2017 11:34:41 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.42 kb |
#include <fstream>
using namespace std;
int d,j,n,nr=0;
bool c[2000001];
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int main()
{
fin>>n;
c[0]=true;
c[1]=true;
for(int d=2;d<=n;d++)
if(c[d]==false)
{
for(j=2;j<=n/d;j++)
c[j*d]=true;
}
for(j=1;j<=n;j++)
if(c[j]==false)
nr++;
fout<<nr;
return 0;
}