Mai intai trebuie sa te autentifici.
Cod sursa(job #1500711)
Utilizator | Data | 12 octombrie 2015 16:47:29 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 100 |
Compilator | cpp | Status | done |
Runda | Arhiva educationala | Marime | 0.53 kb |
#include <bits/stdc++.h>
using namespace std;
ifstream in ("ciur.in");
ofstream out ("ciur.out");
const int Nmax = 2e6+5;
int k, Prime[Nmax];
bool viz[Nmax];
void ciur(int n){
k=1;// nr 2
for(int i = 3; i <= n; i= i+2)
{
if(viz[i] == 0){
k++;
for(int j = 3 * i; j <= n; j = j + (2 * i)){
viz[j] = 1;
}
}
}
}
int main()
{
int n;
in>>n;
ciur(n);
out<<k;
return 0;
}