Pagini recente » Infoarena Monthly 2014, Clasament Runda 3 | Cod sursa (job #549922) | Cod sursa (job #496484) | Cod sursa (job #494277) | Cod sursa (job #2169778)
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
int v[2000000];
int main()
{
int n, k = 1, i, j;
fin >> n;
if(n <= 1)
fout << 0;
else if(n == 2)
fout << k;
else
for(i = 3; i <= n; i += 2)
{
if(v[i] == 0)
k++;
else for(j = i * 2; j <= n; j += i)
v[j] = 1;
}
fout << k;
fin.close();
fout.close();
return 0;
}