题解 | #质因数的个数#
质因数的个数
https://www.nowcoder.com/practice/20426b85f7fc4ba8b0844cc04807fbd9
#include <cmath> #include <iostream> #include <algorithm> using namespace std; int main() { int n; while(cin>>n){ int cnt=0; int t=n; for(int i=2;i<=t/i;i++){ while(n%i==0){ n/=i; cnt++; } } if(n>sqrt(t)) cnt++; cout<<cnt<<endl; } }