Pagini recente » Cod sursa (job #2949379) | Cod sursa (job #2749698) | Cod sursa (job #1700382) | Cod sursa (job #1157434) | Cod sursa (job #2377094)
#include <bits/stdc++.h>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
bitset<2000000> a;
int n;
int main()
{
int i , j , cnt;
n = 2000000;
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] == 0)
for (j = i * i ; j <= n ; j += 2 * i)
a[j] = 1;
fin >> n;
cnt = 0;
for (i = 2 ; i <= n ; i++)
if (a[i] == 0) cnt++;
fout << cnt << "\n";
return 0;
}