Cod sursa(job #422532)
| Utilizator | Data | 22 martie 2010 19:50:54 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.43 kb |
// ciurul lui eratostene.cpp : Defines the entry point for the console application.
//
using namespace std;
#include<fstream>
long long n,prim[2000005];
ifstream f("ciur.in");
ofstream g("ciur.out");
int main()
{
f>>n;
long long i,j,index=1;
for(i=2;i<=n;i++)
prim[i]=1;
for(i=2;i<=n;i++)
{
if(prim[i])
{
index++;
for(j=i+i;j<=n;j+=i)
{
prim[j]=0;
}
}
}
g<<index;
;
return 0;
}
