算术基本定理

1)一个大于1的正整数N,如果它的标准分解式为:

  

,那么它的正因数个数为

  

代码实现:

      

 LL cnt = 0;

        for(int i=0; i < ans && primes[i] * primes[i] <= S; i++)    //ans是primes中质数的个数

        {

            LL cnt2 = 0;                                 

            while(S % primes[i] == 0)

            {

                cnt2++;

                S /= primes[i];

 

            }

            if(S > 0){

                base[cnt] = primes[i]; //base中是底数

                mi[cnt++] = cnt2; //cnt2是幂的个数

            }

        }

 

2) 它的全体正因数之和为

  

猜你喜欢

转载自www.cnblogs.com/WTSRUVF/p/9178601.html