Cod sursa(job #1883249)
Utilizator | Data | 17 februarie 2017 20:34:08 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 90 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.46 kb |
#include <fstream>
using namespace std;
ifstream cin ("ciur.in") ;
ofstream cout ("ciur.out") ;
const int MAX=2e6;
bool KillMyselfWithASpoon [MAX];
int main()
{
int n;
cin>>n;
int S=0;
for (int i=2; i<=n; i++){
if (KillMyselfWithASpoon [i]==0) {
for (int j=i; j<=n; j+=i){
KillMyselfWithASpoon [j]=1;
}
S=S+1;
}
}
cout<<S;
return 0;
}