Cod sursa(job #2564563)
Utilizator | Data | 1 martie 2020 23:11:43 | |
---|---|---|---|
Problema | Ciurul lui Eratosthenes | Scor | 30 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 0.33 kb |
#include<stdio.h>
#define max 2000001
int p[max];
int n;
int main(){
freopen("ciur.in","r",stdin);
freopen("ciur.out","w",stdout);
scanf("%d",&n);
p[1] = 1;
for(int i=2;i<=n;i++){
if(p[i]) continue;
int j = 2;
while(j<=n/i+1){
p[i*j]=1;
j++;
}
}
int c=0;
for(int i=1;i<=n;i++) if(!p[i]) c++;
printf("%d",c);
}