#include <cstdio> int p[1000001], n; main(){ p[1]=1; for(int i=2; i*i<=1000000; i++) if(!p[i]) for(int j=i*2; j<=1000000; j+=i) p[j]=1; while(scanf("%d", &n)==1&&n) printf("%d\n", p[n]); }
#include int p[1000001], n; main(){ p[1]=1; for(int i=2; i*i<=1000000; i++) if(!p[i]) for(int j=i*2; j<=1000000; j+=i) p[j]=1; while(scanf("%d", &n)==1&&n) printf("%d\n", p[n]); }
你沒有初始陣列