Cod sursa(job #2087624)
Utilizator | Data | 13 decembrie 2017 21:36:39 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.32 kb |
#include <iostream>
#include<fstream>
using namespace std;
int x ,i,n,j,p;
bool a[1000000];
int main()
{ifstream f("ciur.in");
ofstream g("ciur.out");
f>>n;
for(i=2;i<=n;i++)
{
if(a[i]==0)
{
for(j=i*i;j<=n;j=j+i)
{
a[j]=1;
}
p++;
}
}
g<<p;
return 0;
}