Cod sursa(job #527214)

Utilizator ISZLAIIszlai Lehel ISZLAI Data 30 ianuarie 2011 22:34:42
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.35 kb
#include <fstream>
#include<iostream>

using namespace std;



int main ()
{
		ifstream f("ciur.in");
		ofstream g("ciur.out");
		int n,j;
		f>>n;
		int a[2000000]={0};
			
		for(int i=2;i<=n;i++)
			{
				if(a[i]==0)
				{j=2;
				while(i*j<=n)
					{a[i*j]=1;
				j++;
				} }
			}
		int db=0;
		for(int i=2;i<=n;i++)
			if(a[i]==0)
				db++;
		g<<db;
		
		}