Cod sursa(job #2778376)
Utilizator | Data | 1 octombrie 2021 11:17:17 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
#include <bitset>
#define limit 2000000
using namespace std;
ifstream cin("ciur.in");
ofstream cout("ciur.out");
bitset <limit + 1> c;
int nr_prime, n;
void eratostene(){
for(int i = 2; i <= n; i++){
if(!c[i]){
nr_prime++;
for(int j = i * i; j <= n; j += i)
c[j] = 1;
}
}
cout << nr_prime;
}
int main(){
cin >> n;
eratostene();
}