Pagini recente » Cod sursa (job #2741240) | Cod sursa (job #1540360) | Cod sursa (job #1379983) | Cod sursa (job #334563) | Cod sursa (job #2077678)
#include <bits/stdc++.h>
using namespace std;
bitset<2000001> a;
int main()
{
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int i, j, n;
fin >> n;
a[0] = a[1] = 1;
for (i = 4; i <= n; i += 2)
a[i] = 1;
for (i = 3; i * i <= n; i += 2)
if (!a[i])
for (j = i * i; j <= n; j += 2 * i) a[j] = 1;
int cnt = 1;
if (n == 2) fout << cnt;
else
{
for (i = 3; i <= n; i += 2)
if (!a[i]) cnt++;
}
fout << cnt;
return 0;
}