Pagini recente » Cod sursa (job #970708) | Cod sursa (job #1206253) | Cod sursa (job #2140258) | Cod sursa (job #1656624) | Cod sursa (job #3175780)
#include <fstream>
using namespace std;
ifstream cin("ciur.in");
ofstream cout("ciur.out");
const int nmax = 2000000;
bool ciur[1000000 + 5];
int main()
{
int i, n, j;
ciur[0] = 1;
for ( i = 3; i * i <= nmax; i += 2 )
if ( ciur[i / 2] == 0 )
for ( j = i * i; j <= nmax; j += 2 * i )
ciur[j / 2] = 1;
cin >> n;
int cnt = 1;
for ( i = 2; i <= n; ++i )
if ( ciur[i / 2] == 0 && i % 2 == 1 )
++cnt;
cout << cnt << endl;
return 0;
}