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