Cod sursa(job #805810)
| Utilizator | Data | 1 noiembrie 2012 10:44:49 | |
|---|---|---|---|
| Problema | Ciurul lui Eratosthenes | Scor | 100 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.4 kb |
#include <fstream>
using namespace std;
ifstream fin("ciur.in");
ofstream fout("ciur.out");
#define lmax 2000005
long unsigned int k,h,v2[lmax]; bool v[lmax];
int main()
{
for(unsigned long int i=2;i<=lmax;i++)
{
if(v[i]==0) {v[i]=1; v2[h++]=i;
for(unsigned long int j=i+i;j<=lmax;j+=i) v[j]=1;}
}
fin>>k;
for(h=0;v2[h]<=k;h++);
fout<<h;
}
