uva10892

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

Consider two numbers a and b, whose prime factorizations are 2^{a_2} 3^{a_3} ... and 2^{b_2} 3^{b_3} ..., respectively. Then their LCM is 2^{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 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 \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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值