Cod sursa(job #2277537)

Utilizator Xutzu358Ignat Alex Xutzu358 Data 6 noiembrie 2018 15:17:10
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.62 kb
#include <iostream>
#include <fstream>
#include <bitset>
#include <vector>
#define nmax 2000005
#define LL long long
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
bitset <nmax> esteprim;
vector <int>pr;
void ciur () {
        for (LL i=2;i<=nmax;i++) {
              if (esteprim[i]==0) {
                  for (LL j=i*i;j<=nmax;j+=i)
                         esteprim[j]=1;

              pr. push_back(i);
              }
        }

}
int n,ctr;
int main()
{
    f >> n;
    ciur();
    for (int a=0;pr[a]<=n;a++)  {
           ctr++;
    }
    g << ctr;

    return 0;
}