#include <stdio.h> #include<math.h> int main() { int num; while (scanf("%d", &num) != EOF) { int kai,i,count = 0,flag = 0; kai = (int)sqrt(num); if(kai*kai == num){num = (int)sqrt(num);flag = 1;} for(i = 2;num != 1;i++){ if(num % i == 0){ count++; num /= i; i = 1; } } if(flag == 1){count *= 2;} printf("%d\n", count); } return 0; }//不要写子函数,够运行的
#include <stdio.h> #include <math.h> int main(){ int x, count = 0, n; scanf("%d", &x); n = sqrt(x); for (int i = 2; i <= n; i ++) { while (x%i==0) { count ++; x/=i; } if (x==1) { break; } } if (x>1) { count ++; } printf("%d\n", count); return 0; }
#include<stdio.h> #include<stdlib.h> #include<math.h> #define max 40000 //判断一个数是否是质数 int panduan(int n){ int i; if(n<2) return 0; for(i=2;i<=sqrt(n);i++){ if(n%i==0) return 0; } return 1; } //筛法求出一段区间内的所有质数 int zhishu(int high,int *a){ int i,j=0,k=2; int *visit; visit=(int*)malloc(sizeof(int)*(high+1)); for(i=0;i<=high;i++) visit[i]=0; visit[0]=1;visit[1]=1; for(i=2;i<=high;i++){ if(visit[i]) continue; if(panduan(i)){ a[j++]=i; } while(k*i<=high){ visit[k*i]=1; k++; } k=2; } return j; } int main(){ int a[max]; int z,n,k=0; int answer=0; z=zhishu(max,a); while(scanf("%d",&n)!=EOF){ while(k<z&&n!=1){ if(n%a[k]==0){ answer++; n=n/a[k]; } else{ k++; } } if(n>1) answer++; printf("%d\n",answer); k=0,answer=0; } }