“质数判断”的版本历史

跳转到导航 跳转到搜索

差异选择:选中要对比的修订的单选按钮,然后按Enter键或下面的按钮。
说明:(当前)=与最后修订的差异,(之前)=与上个修订的差异,=小编辑。

2026年2月12日 (星期四)

  • 当前之前 08:552026年2月12日 (四) 08:55 33DAI 留言 贡献 1,388字节 +1,388 创建页面,内容为“==判断单个质数== <math>O(\sqrt{x})</math> <syntaxhighlight lang="cpp" line> bool is_prime(long long x) { if (x < 2) return false; for (long long i = 2; i * i <= x; i++) if (x % i == 0) return false; return true; } </syntaxhighlight> ==筛法== ===埃氏筛=== <math>O(n\log \log n)</math> <syntaxhighlight lang="cpp" line> const int MAXN = 10'000'000; bool p[MAXN + 1]; //筛出 1~n 中的每个数是否为质数…”