Cod sursa(job #2356323)

Utilizator teodornastase9Nastase Gheorghe Teodor teodornastase9 Data 26 februarie 2019 16:54:50
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.38 kb
#include <bits/stdc++.h>

using namespace std;

ifstream f("eratostene.in");
ofstream g("eratostene.out");

bool p[10000000000];
int n,j,i,nr;

int main()
{
  f>>n;
  nr=0;
  for (i=2;i<=n;i++)
    {if (p[i]==0)
             {

                for(j=i+i;j<=n;j=j+i)
                     p[j]=1;
                     nr++;
    }

    }
g<<nr;
    return 0;
}