Cod sursa(job #2385263)
| Utilizator | Data | 21 martie 2019 19:00:59 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp-64 | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
long long n,a,b,i,j,nr;
const int N = 2e6+5;
bitset <N> primes;
int main()
{
fin>>n;
primes.set();
for (i=2; i<=n; i++)
{
if (primes[i]==1)
{
nr++;
for (j = 2; i*j <= n; j++)
primes[i*j]=0;
}
}
fout<<nr;
return 0;
}
