这里面似乎会对某些数标记了很多次其为合数
作者:互联网
线性筛法
以上做法仍有优化空间,我们发现这里面似乎会对某些数标记了很多次其为合数。有没有什么办法省掉无意义的步骤呢?
答案当然是:有!
如果能让每个合数都只被标记一次,那么时间复杂度就可以降到 O(n)O(n) 了
https://www.xiachufang.com/recipe/105861612/
http://www.xiachufang.com/recipe/105861612/printable/
http://www.xiachufang.com/recipe/105861612/
https://www.xiachufang.com/recipe/105861613/
http://www.xiachufang.com/recipe/105861613/printable/
http://www.xiachufang.com/recipe/105861613/
https://www.xiachufang.com/recipe/105861614/
http://www.xiachufang.com/recipe/105861614/printable/
http://www.xiachufang.com/recipe/105861614/
https://www.xiachufang.com/recipe/105861615/
http://www.xiachufang.com/recipe/105861615/printable/
http://www.xiachufang.com/recipe/105861615/
https://www.xiachufang.com/recipe/105861616/
http://www.xiachufang.com/recipe/105861616/printable/
http://www.xiachufang.com/recipe/105861616/
https://www.xiachufang.com/recipe/105861617/
http://www.xiachufang.com/recipe/105861617/printable/
http://www.xiachufang.com/recipe/105861617/
标签:www,http,标记,xiachufang,合数,recipe,printable,其为,com 来源: https://www.cnblogs.com/cssmas/p/13507371.html