来自 http://projecteuler.net/index.php?section=problems&id=99
Comparing two numbers written in index form like 211 and 37 is not difficult, as any calculator would confirm that 211 = 2048 37 = 2187.
However, confirming that 632382518061 > 519432525806 would be much more difficult, as both numbers contain over three million digits.
Using base_exp.txt (right click and 'Save Link/Target As...'), a 22K text file containing one thousand lines with a base/exponent pair on each line, determine which line number has the greatest numerical value.
我该如何处理?
最佳答案
不是完整的解决方案,而是一些想法。您可以使用以下公式:
log(ax) = x*loga
log10 可以很容易地估计为位数。通过计算右移可以很容易地估计 log2。
根据以上内容,您可以显着缩小列表范围。对于剩余的数字,您必须进行完整的计算。欧拉项目中是否允许使用数学函数?如果是,最好使用对数。
关于ProjectEuler 问题 99 的算法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/438555/