ProjectEuler 问题 99 的算法

标签 algorithm math

来自 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/

相关文章:

python - 二次复杂度的 4SUM 变化(Python 3.5)

algorithm - 目的是通过内存操作将 MMIX 汇编中的最低有效位设置为 0?

algorithm - 获取 n! 行列式的有效方法xn! Maple 中的矩阵

java - 以贪婪的方式分配给定的数字

delphi - IPv6 地址的算术(大整数)

查找子序列序列的算法

c# - 如何使用循环在 C# 中计算 pi 到 N 个位置

math - 点到多面体或多边形的距离

math - 计算变换原点 X、Y 值

arrays - 如何在 go-lang 中创建一组正态分布的数字,围绕特定数字设置