Cod sursa(job #566056)
Utilizator | Data | 28 martie 2011 16:53:07 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <fstream.h>
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
{c=2;
d=7;
while (d<=N)
{OK=1;
for (i=2; i<=d/2; i++)
if (d%i==0)
OK=0;
if (OK==1)
c=c+1;
d=d+2;}
}
h<<c<<endl;
f.close();
h.close();
return 0;
}