Pagini recente » Cod sursa (job #243517) | Cod sursa (job #2129461) | Cod sursa (job #201203) | Cod sursa (job #3175918) | Cod sursa (job #2104866)
#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[i] = 1;
int cnt = 0;
for(int i = 2; i <= n; i++)
if(a[i] == 0)
cnt++;
fout << cnt << "\n";
return 0;
}