Pagini recente » Cod sursa (job #799652) | Cod sursa (job #1047311) | Cod sursa (job #831634) | Cod sursa (job #69186) | Cod sursa (job #2330094)
#include <fstream>
#include <vector>
int main()
{
std::ifstream fin("ciur.in");
std::ofstream fout("ciur.out");
int n;
fin >> n;
int cnt = 1, stop = (n - 3) / 2;
std::vector<bool> is_prim(stop + 1, true);
if (n > 2)
{
for (int i = 0; i <= stop; ++i)
if (is_prim[i])
{
cnt++;
for (int j = i + 2 * i + 3; j <= stop; j += 2 * i + 3)
is_prim[j] = false;
}
}
fout << cnt << std::endl;
return 0;
}