首页 > 其他 > 详细

SPOJ #2 Prime Generator

时间:2014-02-04 02:29:40      阅读:416      评论:0      收藏:0      [点我收藏+]

My first idea was Sieve of Eratosthenes, too. But obviously my coding was not optimal and it exceeded 6s time limit. Then I googled it. Sounds like Miller-Rabin Testing is a much more serious solution. http://www.cnblogs.com/feature/articles/1824667.html It is based on Fermat Little Theory and property of square root of unity. But the practical use of this method was not satisfactory - it is not 100% accurate - flawness with P of 1/(4^k) - k the MR testing times.

But it is only #2 in SPOJ, it doesn‘t require too much number theory stuff, and Sieve of Eratosthenes works - as long you code it in smart way. Check it out here: http://jamie-wong.com/2009/11/12/spoj-problem-2-prime-generator/

SPOJ #2 Prime Generator

原文:http://www.cnblogs.com/tonix/p/3537547.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!