boolis_prime(int x){if(x <2)returnfalse;for(int i =2; i <= x / i; i ++)if(x % i ==0)returnfalse;returntrue;}
试除法判断质因数
voiddivide(int x){for(int i =2; i <= x / i; i ++)if(x % i ==0){int s =0;while(x % i ==0) x /= i, s ++;
cout << i <<' '<< s << endl;}if(x >1) cout << x <<' '<<1<< endl;
cout << endl;}
朴素筛查素数
int primes[N], cnt;// primes[]存储所有素数bool st[N];// st[x]存储x是否被筛掉voidget_primes(int n){for(int i =2; i <= n; i ++){if(st[i])continue;
primes[cnt ++]= i;for(int j = i + i; j <= n; j += i)
st[j]=true;}}
判断质数bool is_prime(int x){ if (x < 2) return false; for (int i = 2; i <= x / i; i ++ ) if (x % i == 0) return false; return true;}试除法判断质因数void divide(int x){ for (int i = 2; i <= x / i; i ++ ) if (x % i =