Cod sursa(job #2019114)
| Utilizator | Data | 6 septembrie 2017 23:11:05 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.33 kb |
#include <bits/stdc++.h>
using namespace std;
bitset <2000004> fv;
int main(int argc, char const *argv[])
{
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
int n;
fin >> n;
int ans = 0;
for (int i = 2; i<=n; ++i)
if (fv[i] == 0)
{
++ans;
for (int j = i+i; j<=n; j+=i)
fv[j] = 1;
}
fout << ans;
return 0;
}