Pagini recente » Cod sursa (job #430201) | Cod sursa (job #5283) | Cod sursa (job #313685) | Cod sursa (job #2131922) | Cod sursa (job #568423)
Cod sursa(job #568423)
#include <fstream.h>
#include<cmath>
using namespace std;
int main()
{long int N, d, c, OK, i;
ifstream f("ciur.in");
ofstream h("ciur.out");
f>>N;
if (N<3)
c=1;
else
if (N<5)
c=2;
else
if (N<7)
c=3;
else
if (N>=7)
{c=3;
d=7;
while (d<=N)
{OK=1;
i=3;
do
{if (d%i==0)
OK=0;
i=i+2;
}
while ((i<=int(sqrt((double)d)))&&(OK==1));
if (OK==1)
c=c+1;
d=d+2;
}
}
h<<c<<endl;
f.close();
h.close();
return 0;
}