ACM
the code of acm, algorithm, mathematics,computer science and Technology
Install / Use
/learn @tiankonguse/ACMREADME
ACM 算法模板
数论
素数
素数个数
素数定理:pi(x) = x/ln(x)
pi(x)表示小于x的素数的个数
// 基础筛法
// 素数个数度:
const int N = 1000000;
const int M = 300000;
bool is[N];
int prm[M];
int getprm() {
int e = (int)(sqrt(0.0 + N) + 1), k = 0, i;
memset(is, 1, sizeof(is));
prm[k++] = 2;
is[0] = is[1] = 0;
for (i = 4; i < N; i += 2) is[i] = 0;
for (i = 3; i < e; i += 2) {
if (is[i]) {
prm[k++] = i;
for (int s = i + i, j = i * i; j < N; j += s) is[j] = 0;
}
}
for (; i < N; i += 2)
if (is[i]) prm[k++] = i;
return k;
}
Related Skills
node-connect
351.8kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
110.9kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
351.8kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
351.8kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
