Cod sursa(job #1365921)
Utilizator | Data | 28 februarie 2015 16:47:01 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.25 kb |
#include <fstream>
using namespace std;
ifstream in("ciur.in");
ofstream out("ciur.out");
bool v[2000001];
int main()
{
int N,i,j,rez=0;
in>>N;
for(i=2;i<=N;i++){
if(v[i]==0){
for(j=i;j<=N;j=j+i){
v[j]=1;
}
rez++;
}
}
out<<rez;
}