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