Cod sursa(job #2691828)

Utilizator tomaionutIDorando tomaionut Data 30 decembrie 2020 11:03:54
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.47 kb
#include <bits/stdc++.h>
#define N 2000000
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
bitset <2000005> b;
int x,sol;
void ciur()
{
    int i,j;
    for (i=4; i<=N; i+=2)
        b[i]=1;
    for (i=3; i*i<=N; i+=2)
        if (b[i]==0)
        for (j=i*i; j<=N; j+=2*i)
        b[j]=1;
    for (i=2; i!=x; i++)
        if (b[i]==0)
            sol++;
    fout << sol;
}
int main()
{
    fin >> x;
    ciur();


    return 0;
}