素数筛 暴力筛 bool prime(int n){ if(n<2) return 0; for(int i=2;i<=sqrt(n);i++){ if(!(n%i)) return 0;//遇到不是1的约数则不是素数,注意运算符优先级问题 } return 1; } 埃式筛 欧拉筛