Cod sursa(job #1839173)
Utilizator | Data | 2 ianuarie 2017 16:01:28 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.31 kb |
#include<fstream>
using namespace std;
ifstream cin("ciur.in");
ofstream cout("ciur.out");
int n, a[2000010], k=0;
int main(){
cin>>n;
for(int i=2; i<=n; i++){
if(a[i]==0){
k++;
int j=2;
while(j*i<=n){
a[i*j]=1;
j++;
}
}
}
cout<<k;
return 0;
}