Pagini recente » Cod sursa (job #1232941) | Cod sursa (job #2583352) | Cod sursa (job #3225439) | Cod sursa (job #302254) | Cod sursa (job #2531439)
#include <bits/stdc++.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
const int NMAX = 2e6 + 5;
int N;
bool Sel[NMAX];
static inline void Eratosthenes (int N)
{
Sel[0] = Sel[1] = 1;
for(int i = 4; i <= N; i += 2)
Sel[i] = 1;
for(int i = 3; i * i <= N; i += 2)
if(!Sel[i])
for(int j = 3; j * i <= N; j += 2)
Sel[i * j] = 1;
return;
}
int main ()
{
f.tie(NULL);
f >> N;
Eratosthenes(N);
int ans = 0;
for(int i = 2; i <= N; ++i)
if(Sel[i])
continue;
else ++ans;
g << ans << '\n';
return 0;
}