Cod sursa(job #158199)

Utilizator mike4problemsRadu Gabriel mike4problems Data 13 martie 2008 15:22:23
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.25 kb
#include<fstream>
using namespace std;

int n,sol=1;
char h[2000001];

ifstream f("ciur.in");
ofstream g("ciur.out");

int main()
{
	int i,j,k;
	f>>n;
	for(i=3;i<=n;i+=2)
		if(!h[i])
		{
			sol++;
			for(j=3*i;j<=n;j+=2*i)
				h[j]=1;
		}
	g<<sol<<'\n';
}