Cod sursa(job #1342836)
Utilizator | Data | 14 februarie 2015 16:10:40 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.26 kb |
#include <fstream>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
bool marc[2000001];
int main()
{
int n,i,j,num=0;
in>>n;
for(int i=2;i<=n;i++){
if(marc[i]==0){
num++;
}
for(j=i;j<=n;j=j+i){
marc[j]=1;
}
}
out<<num;
}