Skip to content

Instantly share code, notes, and snippets.

@masnnuller
Created July 9, 2012 14:35
Show Gist options
  • Save masnnuller/3076903 to your computer and use it in GitHub Desktop.
Save masnnuller/3076903 to your computer and use it in GitHub Desktop.
0011
#include <stdio.h>
int main(void){
int k,j,a;
char flag[1000000]={1,1};//0,1は除外する
for(k=2;k<1000;k++){
if(flag[k]==0){
for(j=k*k;j<1000000;j+=k)
flag[j]=1;
}
}
while(~scanf("%d",&a)){
k=0;
for(j=2;j<=a;j++) if(flag[j]==0) k++;
printf("%d\n",k);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment