Divided numbers and sum of divisor knowledge points (including formulas)

foreword

I learned the formula for the sum of divisors when I was studying the eighth lecture of the Acwing c++ Blue Bridge Cup Tutorial Course - AcWing 1296. Smart Stefanie , here are the knowledge points.

The current article has been included in the blog file directory index: blog directory index (continuously updated)


Approximate Knowledge Points

Divided numbers, sum formulas of divisors and proof examples

Formula 1, the number of divisors of N is (a1+1)(a2+1)...(an+1)

Proof: Suppose a divisor of N is D, D = P1 b1 * P2 b2 * ... * Pn bn , where bi can be taken to 0, and the range is 0<= bi <= ai

Because only the one-to-one correspondence with the prime factor of N can definitely get the divisor, because bi can be taken from 0 to ai, then there are (ai+1) selection methods for each bi, and the number of divisors is each bi Corresponding to how many selection methods are multiplied.

Formula 2, sum of divisors S = (1+p1+p1 2 +…+p1 a1 )(1+p2+p2 2 +…+p2 a2 )…(1+pn+pn 2 +…+pn an )

Proof: Since each divisor is D = P1 b1 * P2 b2 * ... * Pn bn , then S = (1+p1+p1 2 +...+p1 a1 )(1+p2+p2 2 +...+p2 a2 ) …(1+pn+pn 2 +…+pn an )

The meaning of this formula is to take a number from each parenthesis and multiply it to get a divisor Di, and then add all the divisors Di to get the sum S of the divisors.

Practical example : For S = 42 (sum of divisors), one of the results corresponding to 42 is 20, and the sum of divisors of 20 is = (1 + 2 + 4 + 5 + 10 + 20)

The formula for converting the number 20 to N: 20 = 2 2 *5, for two prime factors 2 and 5, 2 can take 0, 1, 2 times, 5 can take 0, 1 times, then we can use Formula: sum of divisors S = (1+p1+p1 2 +…+p1 a1 )(1+p2+p2 2 +…+p2 a2 )…(1+pn+pn 2 +…+pn an ), as as follows:

So S = (1+2+2 2 )(1+5) = 42


related topics

AcWing 1296. Clever Stefanie (Medium)


reference article

[1]. AcWing 1296. Smart Stefanie-Problem Solution

おすすめ

転載: blog.csdn.net/cl939974883/article/details/128756317