• 「学习笔记」整除(数论)分块


    数论分块

    对于一个包含 (left lfloor dfrac{n}{i} ight floor) 的求和式子,如:

    [sum_{i = 1} ^ {n} left lfloor dfrac{n}{i} ight floor ]

    会出现许多 (left lfloor dfrac{n}{i} ight floor = left lfloor dfrac{n}{j} ight floor = x (i eq j)) 的情况。

    我们要对于每一个 (x) 找到一个最大的 (j) 使得(left lfloor dfrac{n}{i} ight floor = left lfloor dfrac{n}{j} ight floor = x)

    这个 (j) 就等于 (left lfloor dfrac{n}{left lfloor dfrac{n}{i} ight floor} ight floor)

    证明

    对于 (left lfloor dfrac{n}{i} ight floor = left lfloor dfrac{n}{j} ight floor (i < j)) 有:

    (egin{cases}left lfloordfrac{n}{i} ight floorleq dfrac{n}{j} = left lfloor dfrac{n}{j} ight floor + r (0leq r < 1) \ dfrac{n}{j + 1} < left lfloor dfrac{n}{i} ight floorend{cases})

    (left lfloordfrac{n}{i} ight floorleq dfrac{n}{j} Rightarrow j leq dfrac{n}{left lfloor dfrac{n}{i} ight floor})

    (dfrac{n}{j + 1} < left lfloor dfrac{n}{i} ight floor Rightarrow dfrac{n}{left lfloor dfrac{n}{i} ight floor} < j + 1)

    综上所述:(j leq dfrac{n}{left lfloor dfrac{n}{i} ight floor} < j + 1)

    (ecause j in mathbb N_{+} herefore j = left lfloor dfrac{n}{left lfloor dfrac{n}{i} ight floor} ight floor)

    复杂度分析

    (forall n in mathbb N_{+}, left | left{ leftlfloordfrac{n}{d} ight floormid d in mathbb N_{+},d leq n ight} ight| leq 2sqrt n)

    其中 (|V|) 表示 (V) 这个集合的元素个数。

    证明:

    对于 (d leq sqrt n) 的部分 (leftlfloordfrac{n}{d} ight floor) 最多有 (sqrt n) 个数。

    对于 (d > sqrt n) 的部分 (leftlfloordfrac{n}{d} ight floor) 最多有 (sqrt n) 种不同的取值。

    证毕。

    所以复杂度为 (O(sqrt n))

    小拓展

    对于下式

    [sum_{i = 1}^{min(n,m)} leftlfloordfrac{n}{i} ight floor leftlfloordfrac{m}{i} ight floor ]

    上文中的 (j) 应该等于 (min(left lfloor dfrac{n}{left lfloor dfrac{n}{i} ight floor} ight floor, left lfloor dfrac{m}{left lfloor dfrac{m}{i} ight floor} ight floor))

    例题

    参考文章

    整除(数论)分块 - Luckyblock - 博客园

    莫比乌斯反演 - OI Wiki

  • 相关阅读:
    ES6 Syntax and Feature Overview
    Javescript——数据类型
    Javescript——变量声明的区别
    React之概述(待续)
    React之简介
    Vue.js学习之简介(待续)
    Build Telemetry for Distributed Services之OpenCensus:Tracing2(待续)
    docker之redis使用
    Build Telemetry for Distributed Services之OpenCensus:C#
    Build Telemetry for Distributed Services之Open Telemetry简介
  • 原文地址:https://www.cnblogs.com/poi-bolg-poi/p/13619701.html
Copyright © 2020-2023  润新知