Pagini recente » Cod sursa (job #1113777) | Cod sursa (job #3219511) | Cod sursa (job #1164902) | Cod sursa (job #165155) | Cod sursa (job #2211494)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
int n, cnt;
bitset<2000002>b;
void ciur () {
for (int i = 4; i <= n; i += 2)
b[i] = 1;
for (int i = 3; i * i <= n; i += 2)
if (b[i] == 0)
for (int j = i * i; j <= n; j += 2 * i)
b[j] = 1;
}
int main()
{
fin >> n;
ciur();
for (int i = 2; i <= n; i++)
if (b[i] == 0)
cnt++;
fout << cnt;
return 0;
}