作者:手机用户2502878261 | 来源:互联网 | 2023-07-19 17:51
PossibleDuplicate:NeedhelpsolvingProjectEulerproblem200可能重复:需要帮助解决ProjectEuler问题200
Possible Duplicate:
Need help solving Project Euler problem 200
可能重复:需要帮助解决Project Euler问题200
Similar to this question
与此问题类似
Project Euler Problem 200.
项目欧拉问题200。
I wrote up a brute force solution in Java that takes several hours to run, and produced the first 500+ sqube numbers, which I thought should be enough. However, none of the answers from 190 to 210 seems to be the correct answer.
我在Java中编写了一个暴力解决方案,需要花费几个小时来运行,并产生了前500个大概数字,我认为应该足够了。然而,从190到210的答案似乎都不是正确的答案。
I'm wondering what I'm doing wrong here and how I could optimize this. Could the problem lie in BigInteger.isProbablePrime()
?
我想知道我在这里做错了什么以及如何优化这个。可能问题在于BigInteger.isProbablePrime()吗?
I'm not sure if Stackoverflow is the best place to ask this, but I seem to be stuck. I've included my code and the generated data.
我不确定Stackoverflow是否是最好的问题,但我似乎陷入困境。我已经包含了我的代码和生成的数据。
I'd really appreciate it if someone would give me some hints or pointers.
如果有人给我一些提示或指示,我真的很感激。
Edit: I've run the program again simply with using the first 500,000 prime numbers; took a day to run but produced the correct answer.
编辑:我只是使用前500,000个素数再次运行程序;花了一天的时间来运行,但产生了正确的答案。
4 个解决方案