Cod sursa(job #1255174)
Utilizator | Data | 4 noiembrie 2014 14:30:15 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.43 kb |
#include <fstream>
#include <bitset>
using namespace std;
ifstream is("ciur.in");
ofstream os("ciur.out");
const int MAX = 2000005;
int n, nr;
bitset<MAX> x;
int main()
{
is >> n;
for ( int i = 2; i <= n; i++ )
if ( !x[i] )
{
nr++;
for ( int j = i + i; j <= n; j += i )
x[j] = 1;
}
os << nr;
is.close();
os.close();
return 0;
}