Pagini recente » Monitorul de evaluare | redsnow_3 | Istoria paginii runda/8922938808215294/clasament | Profil MihaelaCismaru | Cod sursa (job #1686087)
#include <fstream>
using namespace std;
bool ciur2[1000000];
long long int tmp2,j,index, n, i, nmax, k,l, tmp;
int main()
{
ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
if(n%2==1)
nmax=n/2;
else
nmax=n/2-1;
for(i = 1; i<=nmax; ++i)
{
if(ciur2[i] == 1) continue;
tmp = 2*i+1;
for(j = tmp*tmp; j<=n; j+=tmp)
{
if(j%2==1)
index=j/2;
else
continue;
ciur2[index] = 1;
}
}
for(i=1;i<=nmax;i++)
if(ciur2[i]==0)
k++;
g<<k;
}