Pagini recente » Cod sursa (job #173922) | Cod sursa (job #1153016) | Cod sursa (job #2551992) | Cod sursa (job #1643904) | Cod sursa (job #1988522)
#include <bits/stdc++.h>
using namespace std;
ifstream fin ("ciur.in");
ofstream fout ("ciur.out");
const int Nmax=2000001;
bitset<Nmax>ciur;
int main()
{
int n, nr = 1;
ciur[0] = 1;
fin >> n;
for (int i=1; ((i * i) << 1) + (i << 1) <= n; i++)
{
if (!ciur[i])
{
for (int j = ((i * i) << 1) + (i << 1); (j << 1) + 1 <= n; j += (i<<1)+1)
ciur[j] = 1;
}
}
for (int i=1; 2 * i + 1 <= n; ++i)
if (ciur[i] == 0) nr++;
fout << nr;
return 0;
}