题解 | #质因数的个数# #C
质因数的个数
https://www.nowcoder.com/practice/20426b85f7fc4ba8b0844cc04807fbd9
#include <math.h> #include <stdio.h> int judge_zhishu(int num){ for (int i=2;i*i<=num;i++){ if (num % i == 0){ return 0; } } return 1; } int main() { int a; while (scanf("%d", &a) != EOF) { int temp = a; int i=sqrt(temp); int count = 0; while (i>1) { if (!judge_zhishu(i)){ i--; }else { if (temp % i == 0){ temp = temp / i; i = sqrt(temp); count ++; }else { i--; } } } printf("%d\n", count+1); } return 0; }#c#