Cod sursa(job #1236578)
Utilizator | Data | 2 octombrie 2014 09:30:12 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.39 kb |
#include <fstream>
#include <cstring>
using namespace std;
ifstream f("ciur.in");
ofstream g("ciur.out");
bool v[2000001];
long long n,i,j,nr;
int main()
{
f>>n;
for(i=1;i<=n;i++) v[i]=true;
for(i=2;i*i<=n;i++)
{
if(v[i])
for(j=2*i;j<=n;j+=i) v[j]=false;
}
for(i=2;i<=n;i++)
if(v[i]==true) nr++;
g<<nr;
return 0;
}