Cod sursa(job #2058179)

Utilizator hhhhhhhAndrei Boaca hhhhhhh Data 5 noiembrie 2017 11:29:22
Problema Ciurul lui Eratosthenes Scor 40
Compilator cpp Status done
Runda Arhiva educationala Marime 0.37 kb
#include <fstream>

using namespace std;
int d,j,n,nr=0;
bool c[1000000];
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)
        {
            nr++;
            for(j=2;j<=n/d;j++)
                c[j*d]=true;
        }
    fout<<nr;
    return 0;
}