Cod sursa(job #2640402)
Utilizator | Data | 6 august 2020 13:07:07 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
bitset<2000001> checked;
int ciurr(int n) {
ll cnt = 0;
for(ll i = 2; i <= n; i++)
if(!checked[i]) {
cnt++;
for(ll j = i * i; j <= n; j += i)
checked[j] = 1;
}
return cnt;
}
int main() {
int n;
fin >> n;
fout << ciurr(n);
return 0;
}