Cod sursa(job #566050)

Utilizator andreea29Iorga Andreea andreea29 Data 28 martie 2011 16:49:21
Problema Ciurul lui Eratosthenes Scor 20
Compilator cpp Status done
Runda Arhiva educationala Marime 0.4 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
	if (N<5)
		c=2;
	else
		if (N<7)
			c=3;
		else
			if (N>=7)
				
{c=3;
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;
}