Cod sursa(job #1647439)
| Utilizator | Data | 10 martie 2016 20:35:16 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.48 kb |
#include <fstream>
#include <bitset>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
bitset<2000001> primes;
int main()
{
unsigned N, counter = 0;
fin >> N;
for(unsigned i = 2; i <= N; ++i)
{
if(!primes[i])
{
++counter;
for(unsigned j = i << 1 ; j <= N; j += i)
primes[j] = 1;
}
}
fout << counter;
fin.close();
fout.close();
return 0;
}
