uva10892

来源:互联网 发布:汉译英最好的软件 编辑:程序博客网 时间:2024/05/19 03:25

求翻译。我翻译出来还是只懂个大概。。求解答这题!

Consider two numbers a and b, whose prime factorizations are 2^{a_2} 3^{a_3} ... and2^{b_2} 3^{b_3} ..., respectively. Then their LCM is2^{max(a_2,b_2)} 3^{max(a_3,b_3)} ... This is the insight that lets us solve the problem.

So factorize N: p_1^{n_1} p_2^{n_2} ... p_k^{n_k}. Now say that we have a and b such that LCM(a,b) = N. Then for each i, at least one ofai 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 ofp1 that divides N. Break the problem into two cases. In case one, we seta1 < b1 =n1. This gives us n1 possibilities for the first number, and for the rest, we can simply take the product of(2ni + 1) fori > 1. (Verify that this does not count any pairs more than once.) In the other case, we havea1 = b1 =n1. In this case, we just need to solve the same problem, but for\frac{N}{p_1^{n_1}}. (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.

原创粉丝点击