Cod sursa(job #264210)
Utilizator | Data | 21 februarie 2009 19:11:24 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.3 kb |
#include<fstream.h>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
#define N 2000000000
int main()
{
long n,i,j,v[N]={0};
f>>n;
for(i=2;i*i<=n;i++) if(v[i]==0) for(j=i*i;j<=n;j+=i) v[j]=1;
for(i=1;i*i<=n;i++) if(v[i]==0) a++;
g<<a;
f.close();
g.close();
return 0;}