• 「考试」省选79


    T1
    分别对序列和值域分块。
    只需要做到(O(sqrt{n}))查询(O(1))修改就可以了。
    这样的话与处理一下序列和值域分块的情况。
    查询的时候动态的处理散块就可以在(O(sqrt{n}))复杂度维护(K)大值。

    T2
    直接推式子。

    [egin{aligned} ans&=sumlimits_{i=1}^{n}sumlimits_{j=1}^{n}sumlimits_{k=1}^{K}f_k(gcd(i,j))\ &=sumlimits_{k=1}^{K}sumlimits_{i=1}^{n}sumlimits_{j=1}^{n}f_k(gcd(i,j))\ &=sumlimits_{k=1}^{K}sumlimits_{d=1}^{n}f_k(d)sumlimits_{i=1}^{frac{n}{d}}sumlimits_{j=1}^{frac{n}{d}}[gcd(i,j)=1]\ &=sumlimits_{k=1}^{K}sumlimits_{d=1}^{n}f_k(d)sumlimits_{i=1}^{frac{n}{d}}sumlimits_{j=1}^{frac{n}{d}}sumlimits_{g|gcd(i,j)}mu(g)\ &=sumlimits_{k=1}^{K}sumlimits_{d=1}^{n}f_k(d)sumlimits_{g=1}^{frac{n}{d}}mu(g)lfloorfrac{n}{dg} floor^2\ &=sumlimits_{k=1}^{K}sumlimits_{T=1}^{n}lfloorfrac{n}{T} floor^2sumlimits_{d|T}mu(d)f_k(frac{T}{d})\ H_k(n)&=sumlimits_{d|n}mu(d)f_k(frac{n}{d})\ H_k&=mu*f_k\ H_k(p^e)&=mu(p^0)f_k(p^e)+mu(p^1)f_k(p^{e-1})\ n=&prodlimits_{i=1}^{w}p_i^{c_i}\ g(n)&=prodlimits_{i=1}^{n}(-1)^{c_i}\ end{aligned}]

    [egin{aligned} ans&=sumlimits_{i=1}^{n}sumlimits_{j=1}^{n}sumlimits_{k=1}^{K}f_k(gcd(i,j))\ &=sumlimits_{k=1}^{K}sumlimits_{i=1}^{n}sumlimits_{j=1}^{n}f_k(gcd(i,j))\ &=sumlimits_{k=1}^{K}sumlimits_{d=1}^{n}f_k(d)sumlimits_{i=1}^{frac{n}{d}}sumlimits_{j=1}^{frac{n}{d}}[gcd(i,j)=1]\ &=sumlimits_{k=1}^{K}sumlimits_{d=1}^{n}f_k(d)left(left(sumlimits_{i=1}^{frac{n}{d}}2varphi(i) ight)-1 ight)\ res&=sumlimits_{k=1}^{K}sumlimits_{d=1}^{n}f_k(d)\ F_k(n)&=sumlimits_{i=1}^{n}f_k(i)\ &=sumlimits_{i=1}^{n}g(i)-sumlimits_{i=2}^{n}(-mu(i))sumlimits_{j=1}^{frac{n}{i^{k+1}}}g(i^{k+1}j)\ &=sumlimits_{i=1}^{n}mu(i)sumlimits_{j=1}^{frac{n}{i^{k+1}}}g(i^{k+1}j)\ &=sumlimits_{i=1}^{sqrt[k+1]{n}}mu(i)g^{k+1}(i)sumlimits_{j=1}^{frac{n}{i^{k+1}}}g(j)\ G(n)&=sumlimits_{i=1}^{n}g(i)\ g*delta&=eta\ sumlimits_{d|n}g(frac{n}{d})&=[exist iin N^{*},i^2=n]\ g*I&=[exist iin N^{*},i^2=n]\ sumlimits_{i=1}^{n}[exist jin N^{*},j^2=i]&=sumlimits_{i=1}^{n}sumlimits_{d|i}g(frac{i}{d})\ &=sumlimits_{d=1}^{n}sumlimits_{i=1}^{frac{n}{d}}g(i)\ &=G(n)+sumlimits_{d=2}^{n}G(frac{n}{d})\ G(n)&=sqrt{n}-sumlimits_{d=2}^{n}G(frac{n}{d})\ end{aligned} ]

    杜教筛就完事了。

    T3
    对于两条序列,有如下结论和证明。

    [a ightarrow b,c ightarrow d ]

    [a ightarrow d,c ightarrow b ]

    [(a,b)cap(c,d)=e,(a,e)+(e,b)+(c,e)+(e,d)=(a,d)+(c,b) ]

    [(a,b)cap(c,d)=emptyset,rt,LCA(a,b),LCA(c,d) ]

    这样我们只需要找到每个点当了多少次起点或者终点,然后按照最小字典序组合起来就可以了。

    [fr=LCA(a,b),se=LCA(c,d) ]

    [(a,fr)+(fr,b)+(c,se)+(se,d)=(a,fr)+(fr,se)+(se,d)+(c,se)+(se,fr)+(fr,b) ]

  • 相关阅读:
    QBoxLayout中setSpacing(int)和addSpacing(int)的区别
    BZOJ1017 树形DP
    树形DP 2415HDU
    树形DP基础题 HDU1520
    最小生成树个数 并查集压缩路径
    伸展树基本概念基本题目
    BZOJ1010单调性DP优化
    BZOJ1009 矩阵快速幂+DP+KMP
    字典树(数组实现)
    poj 1611 The Suspects(并查集输出集合个数)
  • 原文地址:https://www.cnblogs.com/Lrefrain/p/12770498.html
Copyright © 2020-2023  润新知