线性筛/欧拉筛/莫比乌斯函数

int pr[N], pr_cnt, flg[N], mu[N], sum_mu[N];
void init() {
    mu[1] = 1;
    for (int i = 2; i < N; i ++) {
        if (!flg[i])pr[++pr_cnt] = i, mu[i] = -1;
        for (int j = 1; j <= pr_cnt && i*1ll * pr[j] < N; j ++) {
            flg[i * pr[j]] = 1;
            if (i%pr[j] == 0) {
                mu[i * pr[j]] = 0;
                break;
            }
            mu[i * pr[j]] = -mu[i];
        }
    }
    for (int i = 1; i < N; i ++) sum_mu[i] = sum_mu[i-1] + mu[i];
}
上一篇:学习JAVA第二十七天


下一篇:Sklearn对多分类的每个类别进行指标评(PR)