Cod sursa(job #1698321)
Utilizator | Data | 4 mai 2016 08:49:02 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
#include <bitset>
using namespace std;
ofstream fout ("ciur.out");
ifstream fin ("ciur.in");
int n , rez;
bitset <2000001> v;
int main()
{
fin>>n;
for( int i = 2 ; i <= n ; i++)
{
if( !v[ i ])
{
for(int j = 2 * i ; j <= n ; j+= i)
{
v[ j ] = 1;
}
}
}
for(int i = n ; i >= 2 ; i-- )
if( !v[ i ]) rez++;
fout<<rez;
}