Pagini recente » Cod sursa (job #63661) | Cod sursa (job #1587207) | Cod sursa (job #3157098) | Cod sursa (job #591305) | Cod sursa (job #2717528)
#include <iostream>
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
const int NMax = 2 * 1e6;
int n, ans;
bool sieve[NMax + 5];
void Read(){
fin >> n;
}
void Eratosthenes(){
for (int i = 2; i <= n; i++)
if (!sieve[i]){
ans++;
for (int j = 2 * i; j <= n; j += i)
sieve[j] = 1;
}
}
void Print(){
fout << ans << '\n';
}
int main(){
Read();
Eratosthenes();
Print();
return 0;
}