十亿丑数还是海明数?
1 billionth ugly or hamming number?
这是第 1 个 ugly/hamming 数吗?
62565096724471903888424537973014890491686968126921250076541212862080934425144389
76692222667734743108165348546009548371249535465997230641841310549077830079108427
08520497989078343041081429889246063472775181069303596625038985214292236784430583
66046734494015674435358781857279355148950650629382822451696203426871312216858487
7816068576714140173718
有没有人可以分享可以验证这一点的代码?谢谢!
This SO answer 显示了能够计算它的代码。
test entry on ideone.com 1.1 0.05 秒 109 (2016-08-18:由于在可能的情况下使用 Int
而不是默认的 Integer
而导致的主要加速,即使在 32 位上也是如此;另外20% 感谢@GordonBGood 建议的调整,将带大小复杂度降低到 O(n1/3)).
给出的答案为((1334,335,404),"6.21607575556559E+843")
,即
21334 * 3335 * 5404 ≈ 6.21607575556559 * 10843.
(巧合的是,上面的小数只有最后两位不正确)
这当然也意味着这个数字末尾有404个零,总共有844位。所以不,你显示的数字不是。
准确答案:
6216075755565244861630816332872072003947056519089652706591632409642337022002753141824417540777256732780370172616615291935540418620025524916729500086831454711313694078635504004160312872951788703647948382456091072701600790562071797590306654765882256990391763887850141154482249915927439184562828227449023750262318234797192076792208033475638322151983772515798004125909334741121595323950448656375104457026997424772966917441779406172736975588556800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000
这是第 1 个 ugly/hamming 数吗?
62565096724471903888424537973014890491686968126921250076541212862080934425144389 76692222667734743108165348546009548371249535465997230641841310549077830079108427 08520497989078343041081429889246063472775181069303596625038985214292236784430583 66046734494015674435358781857279355148950650629382822451696203426871312216858487 7816068576714140173718
有没有人可以分享可以验证这一点的代码?谢谢!
This SO answer 显示了能够计算它的代码。
test entry on ideone.com 1.1 0.05 秒 109 (2016-08-18:由于在可能的情况下使用 Int
而不是默认的 Integer
而导致的主要加速,即使在 32 位上也是如此;另外20% 感谢@GordonBGood 建议的调整,将带大小复杂度降低到 O(n1/3)).
给出的答案为((1334,335,404),"6.21607575556559E+843")
,即
21334 * 3335 * 5404 ≈ 6.21607575556559 * 10843.
(巧合的是,上面的小数只有最后两位不正确)
这当然也意味着这个数字末尾有404个零,总共有844位。所以不,你显示的数字不是。
准确答案: 6216075755565244861630816332872072003947056519089652706591632409642337022002753141824417540777256732780370172616615291935540418620025524916729500086831454711313694078635504004160312872951788703647948382456091072701600790562071797590306654765882256990391763887850141154482249915927439184562828227449023750262318234797192076792208033475638322151983772515798004125909334741121595323950448656375104457026997424772966917441779406172736975588556800000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000