Cod sursa(job #2197728)
Utilizator | Data | 22 aprilie 2018 19:46:55 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.49 kb |
#include <iostream>
#include <fstream>
#include <bitset>
#define NUM 2000005
using namespace std;
bitset<NUM> ciur;
int n, total;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
cin >> n;
for(int i = 2; i <= n; ++i)
{
if(!ciur[i])
{
total++;
for(int d = i + i; d <= n; d += i)
{
ciur[d] = 1;
}
}
}
cout << total;
f.close();
g.close();
}