Cod sursa(job #2294884)
Utilizator | Data | 2 decembrie 2018 22:01:11 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.4 kb |
#include <cstdio>
using namespace std;
int main(){
freopen("ciur.in", "r", stdin);
freopen("ciur.out", "w", stdout);
int N, k;
int p[2000000];
printf("%d", &N);
for(int i = 2; i <= N; ++i){
if(p[i] == 0){
k++;
for(int j = i+i; j <= N/i; j += i){
p[j] = 1;
}
}
}
printf("%d\n", k);
}