Pagini recente » Cod sursa (job #1908941) | Cod sursa (job #2047678) | Cod sursa (job #1046427) | Cod sursa (job #2826787) | Cod sursa (job #2549833)
#include <iostream>
#include <fstream>
#include <bitset>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int n;
bitset<2000001> P;
void Ciur()
{
P.set();
P[0] = P[1] = false;
for (int i = 2; i * i <= n; ++i)
{
if (P[i])
{
for (int j = i * i; j <= n; j += i)
P[j] = false;
}
}
}
int main()
{
int cnt = 0;
fin >> n;
Ciur();
for (int i = 1; i <= n; ++i)
{
if (P[i])
++cnt;
}
fout << cnt;
return 0;
}