/* * 质因数个数(使用到质数筛法) */ #include <iostream> #include <cstdio> #include <vector> #include <math.h> using namespace std; const int MAXN = 1e5; bool isPrime[MAXN]; //标记数组 vector<int> prime; //保存质数 void initial(){ //初始化 fill(isPrime,isPrime+MAXN,true); isPrime[0]=false; isPrime[1]=false; for(int i = 2;i<MAXN;i++){ if(!isPrime[i]){ //非质数,则跳过该数 continue; } prime.push_back(i); for(int j = i+i;j<MAXN;j+=i){ isPrime[j]=false; //质数的倍数为非质数 } } return; } int main(){ initial(); int n; int sqr = (int)sqrt(1.0*n); while(scanf("%d",&n)!=EOF){ if(n==1){ printf("1\n"); } int sum = 0; for(int i = 0;i<prime.size();i++){ int cursum=0; int factor = prime[i]; if(n<factor){ break; } while(n%factor==0){ cursum++; n = n/factor; } sum+=cursum; } if(n>1){ sum++; } printf("%d\n",sum); } return 0; }