Cod sursa(job #301506)

Utilizator LAURAMLAURA M LAURAM Data 8 aprilie 2009 11:40:34
Problema Ciurul lui Eratosthenes Scor 0
Compilator cpp Status done
Runda Arhiva educationala Marime 0.34 kb
#include<iostream.h>
#include<fstream.h>
using namespace std;
char prim[2000010];
int nr=0,i,j,n;
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{ f<<n;
prim[1]=0;
for(i=2;i<=n;i++)
prim[i]=1;
for(i=2;i<=n;i++)
if(prim[i])
for(j=i+i;j<=n;j+=i;)
prim([j])=0;
for(i=1;i<=n;i++)
if(prim[i]) nr++;
g>>nr;
return 0;
}