求翻译。我翻译出来还是只懂个大概。。求解答这题!
Consider two numbers a and b, whose prime factorizations are and
, respectively. Then their LCM is
This is the insight that lets us solve the problem.
So factorize N: . Now say that we have a and b such that LCM(a,b) = N. Then for each i, at least one of
ai and
bi is equal to
ni. This would suggest that there are
2ni + 1 possibilities for each prime factor, and that if we multiply them all together, we're done. Unfortunately, we run into the issue of overcounting. Thus we need to modify this approach somewhat. We will solve this problem
incrementally and recursively.
For a given N, call the smallest prime factor
p1, and say that n1 is the largest power of
p1 that divides N. Break the problem into two cases. In case one, we set
a1 < b1 =
n1. This gives us n1 possibilities for the first number, and for the rest, we can simply take the product of
(2ni + 1) for
i > 1. (Verify that this does not count any pairs more than once.) In the other case, we have
a1 = b1 =
n1. In this case, we just need to solve the same problem, but for
. (Similarly, verify that these two cases together do not miss any pairs.) The base case of our recursion is when N = 1, in which
case we just return 1.