Cod sursa(job #668150)

Utilizator feelshiftFeelshift feelshift Data 24 ianuarie 2012 14:10:30
Problema Ciurul lui Eratosthenes Scor 100
Compilator cpp Status done
Runda Arhiva educationala Marime 0.61 kb
// http://infoarena.ro/problema/ciur
#include <fstream>
using namespace std;

const int MAXSIZE = 2000001;

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

int length,answer;
bool numbers[MAXSIZE];

void eratosthenes();

int main()
{
	in >> length;
	in.close();


    int stop = length / 2;
        for(int i=3;i<=length;i+=2)
            if(!numbers[i])
            {
             for(int k=i;k<=length;k=k+(i << 1))
                    numbers[k] = true;
                answer++;
            }

	out << ++answer << "\n";
	out.close();

	return (0);
}

void eratosthenes()
{

}