Cod sursa(job #2397379)

Utilizator bogikanagyNagy Boglarka bogikanagy Data 4 aprilie 2019 12:48:27
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.5 kb
//#include <iostream>
#include <fstream>

using namespace std;
ifstream cin ("ciur.in");
ofstream cout ("ciur.out");


bool x[2000001];
long long i,j,n;
int main()
{
    cin>>n;
    for (i=2;i<=10;++i)
    {
        if (!x[i])
        {
            j=1;
            while (i*j<=n)
            {
                j++;
                x[i*j]=true;
            }
        }
    }

    int db;
    db=0;
    for (i=2;i<=n;++i) if (x[i]==false) db++;

    cout<<db;
    return 0;
}