Cod sursa(job #1967976)

Utilizator tolick2017anatolie tolick2017 Data 17 aprilie 2017 13:06:44
Problema Ciurul lui Eratosthenes Scor 80
Compilator cpp Status done
Runda Arhiva educationala Marime 0.36 kb
#include <fstream>
#include <bitset>
using namespace std;
bitset <2000002> a;
int main()
{
    ifstream f("ciur.in");
    ofstream g("ciur.out");
    int n;
    f>>n;
    int nrtot=0;

for (int i=2; i<=n; i++)
{
if (a[i]==0) nrtot++;
   for (int j=i+i; j<=n; j+=i)
    a[j]=1;




}


    g << nrtot;
f.close();
g.close();
    return 0;
}