莫比乌斯反演学习笔记

莫比乌斯反演

数论函数

数论函数是指定义域为正整数的一类函数。

基本的数论函数

  • 恒等函数\(I(n)=1\)
  • 元函数\(e(n)=[n=1]\)
  • 单位函数\(id(n)=n\)
  • 莫比乌斯函数

\[\mu(n)=\begin{cases} 0, & n的约数中包含大于1的完全平方数 \\ (-1)^k, & k为x含有的质因子种类数 \end{cases} \]

  • 欧拉函数\(\varphi(n)=小于等于n且与n互质的正整数个数\)

积性函数

称一个数论函数\(f\)为积性函数,当且仅当\(\forall a,b\subseteq\mathbb{N}^*\operatorname{gcd}\left( a,b \right) =1\)满足$f\left( a \right) \cdot f\left( b \right) =f\left( a\cdot b \right) $。

若一个数论函数满足\(\forall a,b\subseteq\mathbb{N}^*\)\(f\left( a \right) \cdot f\left( b \right) =f\left( a\cdot b \right)\)则称数论函数\(f\)为完全积性函数。

狄利克雷卷积

狄利克雷卷积是定义在两个数论函数上的二元运算,$$\left( f*g \right) \left( n \right) = \sum_{d|n}f(d)\cdot g\left( \frac{n}{d} \right) $$
这样得到的新数论函数就称为\(f\)\(g\)的狄利克雷卷积。

下面是狄利克雷卷积的一些性质:

  • 狄利克雷卷积具有交换律和结合律。

  • 两个积性函数的狄利克雷卷积还是积性函数

    • proof:

      \[\begin{aligned} &\forall a,b\subseteq \mathbb{N}^*,\operatorname{gcd}\left( a,b \right) =1 \\ &{\kern 15pt}\sum_{d|a}f\left( d \right) \cdot g\left( \frac{a}{d} \right) \times \sum_{d|b} f\left( d \right) \cdot g\left( \frac{b}{d} \right)\\ &=\sum_{d_1|a,d_2|b} f\left( d_1 \right) \cdot g\left( \frac{a}{d_1} \right) \times f\left( d_2 \right) \cdot g\left( \frac{b}{d_2} \right) \\ &=\sum_{d_1|a,d_2|b} f\left( d_1\cdot d_2 \right) \cdot g\left( \frac{a}{d_1} \cdot \frac{b}{d_2}\right)\\ &=\sum_{d|ab}f\left( d \right) \cdot g\left( \frac{ab}{d} \right) \\ \end{aligned} \]

  • 若两个数论函数\(f,g\)满足\(f*g=e\)则称\(f,g\)互为对方的逆。

  • 任何一个满足\(f(1)\neq 0\)的数论函数都存在逆

    • 我们已知一个函数\(f(n)\),设\(g(n)=\frac{e(n)-\sum\limits_{d|n,d≠1}f(d)\cdot g\left( \frac{n}{d} \right) }{f(1)}\)
      \((f*g)(n)=\sum\limits_{d|n}f(d)\cdot g\left( \frac{n}{d} \right)\)
      \(=\sum\limits_{d|n,d≠1}f(d)\cdot g\left( \frac{n}{d} \right)+f(1)\cdot g(n)\)
      \(=\sum\limits_{d|n,d≠1}f(d)\cdot g\left( \frac{n}{d} \right)+f(1)\cdot \frac{\left(e-\sum\limits_{d|n,d≠1}f(d)\cdot g\left( \frac{n}{d} \right)\right)}{f(1)}\)
      \(=\sum\limits_{d|n,d≠1}f(d)\cdot g\left( \frac{n}{d} \right)+e(n)-\sum\limits_{d|n,d≠1}f(d)\cdot g\left( \frac{n}{d} \right)\)
      \(=e(n)\)
  • 积性函数的逆还是积性函数

    • proof:

      \[\begin{aligned} &g(1)\cdot f(1)=e(1)=1 \\ &假设\forall n,m\subseteq\mathbb{N}^*,\operatorname{gcd}(n,m)=1,n\cdot m\leq k有g(n\cdot m)=g(n)\cdot g(m) \\ &则当n\cdot m=k+1时\\ &g(n)\cdot g(m)=\left( -\sum\limits_{d|n,d\neq 1}f(d)\cdot g\left( \frac{n}{d} \right) \right)\cdot \left( -\sum\limits_{d|m,d\neq 1}f(d)\cdot g\left( \frac{m}{d} \right) \right) \\ &{\kern 48pt}=\sum\limits_{d_1|n,d_2|m,d_1\neq 1,d_2\neq 1}f(d_1)\cdot g\left( \frac{n}{d_1} \right)\cdot f(d_2)\cdot g\left( \frac{m}{d_2} \right)\\ &{\kern 48pt}=\sum\limits_{d|n\cdot m,d\neq 1}f(d)\cdot g\left( \frac{n\cdot m}{d} \right) - f(n)\cdot \sum\limits_{d|n,d\neq 1}f(d)\cdot g\left( \frac{n}{d} \right)-f(m)\cdot \sum\limits_{d|m,d\neq 1}f(d)\cdot g\left( \frac{m}{d} \right) \\ &{\kern 48pt}=-g(n\cdot m)+2\cdot g(n)\cdot g(m) \\ &因此g(n\cdot m)=g(n)\cdot g(m),由归纳法可知g(n)为积性函数 \end{aligned} \]

莫比乌斯函数

对于数论函数\(F,f\)其中\(F\)易求,\(f\)难求。如果满足\(F(n)=\sum\limits_{d|n}f(d)\)我们可以利用\(F\)反推出\(f\)

注意到,\(F=f*I\Rightarrow F*I^{-1}=f\)我们只需要研究\(I^{-1}\)的性质。事实上这个函数就是莫比乌斯函数\(\mu(n)\)

由积性函数的逆还是积性函数可知,\(\mu(n)\)也是积性函数。其中\(\mu(1)\cdot I(1)=e(1)=1\Rightarrow \mu(1)=1\)

研究积性函数一般先从质数的情况入手。\(\forall p\subseteq prime,\mu(p)\cdot I(1)+\mu(1)\cdot I(p)=e(p)=0\Rightarrow \mu(p)=-1\)

再来研究质数的幂次的情况。\(\sum\limits_{d|p^k}\mu(d)\cdot I\left( \frac{p^k}{d} \right) = e(p^k)=0\Rightarrow \mu(1)+\mu(p)+\mu(p^2)+ \cdots +\mu(p^k)=0\)可以归纳推出\(\mu(p^k)=0(k\ge 2)\)

这样我们就得到了莫比乌斯函数的完整定义$$\mu(n)=\begin{cases} 0, & n的约数中包含大于1的完全平方数 \ (-1)^k, & k为x含有的质因子种类数 \end{cases}$$

莫比乌斯反演的几种形式

  • 定义形式:\(\sum\limits_{d|n}\mu(d)=[n=1]\)
    变体:\([n=m]=[m|n]\cdot [\frac{n}{m}=1]=[m|n]\cdot \sum\limits_{d|\frac{n}{m}}\mu(d)\)

  • 约数形式:如果\(F(n)=\sum\limits_{d|n}f(d)\)我们可以得到$f(n)=\sum\limits_{d|n}\mu(d)\cdot F\left( \frac{n}{d} \right) $

  • 倍数形式:
    如果\(F(n)=\sum\limits_{k=1}^{+\infty}f(k\cdot n)\)那么\(f(n)=\sum\limits_{k=1}^{+\infty}\mu(k)\cdot F(k\cdot n)\)

    • proof:

      \[\begin{aligned} &{\kern 12pt}\sum\limits_{k=1}^{+\infty}\mu(k)\cdot F(k\cdot n) \\ &=\sum\limits_{k=1}^{+\infty}\mu(k)\sum\limits_{i=1}^{+\infty}f(i\cdot k\cdot n) \\ &=\sum\limits_{i=1}^{+\infty}f(i\cdot n)\sum\limits_{k|i}\mu(k)\\ &=\sum\limits_{i=1}^{+\infty}f(i\cdot n)\cdot [i=1]\\ &=f(n) \end{aligned} \]

一些例子

  • \(求\sum\limits_{i=1}^n\sum\limits_{j=1}^m[\operatorname{gcd}(i,j)=1]\)

    \[\begin{aligned} &{\kern 12pt}\sum\limits_{i=1}^n\sum\limits_{j=1}^m[\operatorname{gcd}(i,j)=1]\\ &=\sum\limits_{i=1}^n\sum\limits_{j=1}^m\sum\limits_{d|\operatorname{gcd}(i,j)}\mu(d)\\ &=\sum\limits_{i=1}^n\sum\limits_{j=1}^m\sum\limits_{d|i,d|j}\mu(d)\\ &=\sum\limits_{d=1}^{\min\left\{ n,m \right\} }\sum\limits_{d|i}\sum\limits_{d|j}1\\ &=\sum\limits_{d=1}^{\min\left\{ n,m \right\} }\mu(d)\cdot \left\lfloor \frac{n}{d} \right\rfloor\cdot \left\lfloor \frac{m}{d} \right\rfloor\\ &接下来就可以直接数论分块了。 \end{aligned} \]

  • \(\sum\limits_{i=1}^n\sum\limits_{j=1}^m[\operatorname{gcd}(i,j)=prime]\quad n,m\leq 10^7,T组数据T\leq 10^4\)

    \[\begin{aligned} &{\kern 18pt}\sum\limits_{i=1}^n\sum\limits_{j=1}^m[\operatorname{gcd}(i,j)=prime] \\ &=\sum\limits_{p\subseteq prime}\sum\limits_{i=1}^n\sum\limits_{j=1}^m[\operatorname{gcd}(i,j)=p]\\ &=\sum\limits_{p\subseteq prime}\sum\limits_{i=1}^n\sum\limits_{j=1}^m[p|\operatorname{gcd}(i,j)]\cdot [\frac{\operatorname{gcd}(i,j)}{p}=1]\\ &=\sum\limits_{p\subseteq prime}\sum\limits_{i=1}^{\left\lfloor \frac{n}{p}\right\rfloor}\sum\limits_{j=1}^{\left\lfloor \frac{m}{p}\right\rfloor}[\frac{\operatorname{gcd}(i\cdot p,j\cdot p)}{p}=1]\\ &=\sum\limits_{p\subseteq prime}\sum\limits_{i=1}^{\left\lfloor \frac{n}{p}\right\rfloor}\sum\limits_{j=1}^{\left\lfloor \frac{m}{p}\right\rfloor}[\operatorname{gcd}(i,j)=1]\\ &=\sum\limits_{p\subseteq prime}\sum\limits_{d=1}^{\min\{\left\lfloor \frac{n}{p} \right\rfloor,\left\lfloor \frac{m}{p} \right\rfloor\}}\mu(d)\cdot \left\lfloor \frac{\left\lfloor \frac{n}{p} \right\rfloor}{d} \right\rfloor\cdot \left\lfloor \frac{\left\lfloor \frac{m}{p} \right\rfloor}{d} \right\rfloor\\ &小trick:\left\lfloor \frac{\left\lfloor \frac{m}{p} \right\rfloor}{d} \right\rfloor=\left\lfloor \frac{m}{p\cdot d} \right\rfloor\\ &{\kern 10pt}proof:设m=k_1\cdot p+r_1(r_1<p),k_1=k_2\cdot d+r_2(r_2<d)\\ &{\kern 46pt}则m=k_2\cdot d\cdot p+p\cdot r_2+r_1\\ &{\kern 46pt}而p\cdot r_2+r_1\leq p\cdot (d-1)+(p-1)=p\cdot d-1\\ &{\kern 46pt}故\left\lfloor \frac{m}{p\cdot d} \right\rfloor=k_2=\left\lfloor \frac{\left\lfloor \frac{m}{p} \right\rfloor}{d} \right\rfloor\\ &枚举p\cdot d:\\ &=\sum\limits_{k=1}^{\min\left\{ n,m \right\} }\left\lfloor \frac{n}{k} \right\rfloor\cdot \left\lfloor \frac{m}{k} \right\rfloor\cdot \sum\limits_{p\subseteq prime,p|k}\mu(\frac{k}{p})\\ &然后前面数论分块,后面可以预处理前缀和。 \end{aligned} \]

  • \(求f(n)=\sum\limits_{d=1}^nd^m\cdot [\operatorname{gcd}(n,d)=1],其中n=\prod\limits_{i=1}^{\omega}p_i^{\alpha_i},\omega\leq 10^3,p_i\subseteq prime,p_i\leq 10^9,\alpha_i\leq 10^9,对10^9+7取模\)

    \[\begin{aligned} &令g(n)=\sum\limits_{i=1}^ni^m,那么g(n)=\sum\limits_{d|n}f(\frac{n}{d})\cdot d^m\\ &\frac{g(n)}{n^m}=\sum\limits_{d|n}f(\frac{n}{d})\cdot \frac{d^m}{n^m}\\ &根据反演公式:\\ &f(n)\cdot \frac{1}{n^m}=\sum\limits_{d|n}\mu(d)\cdot \frac{g(\frac{n}{d})}{\left( \frac{n}{d} \right) ^m}\\ &f(n)=\sum\limits_{d|n}\mu(d)\cdot d^m\cdot g(\frac{n}{d})\\ &函数g(n)可以表示成关于n的m+1次多项式,设g(n)=\sum\limits_{i=0}^{m+1}f_i\cdot n^i\\ &f(n)=\sum\limits_{d|n}\mu(d)\cdot d^m\cdot\sum\limits_{i=0}^{m+1}f_i\cdot \left( \frac{n}{d} \right) ^i\\ &{\kern 20pt}=\sum\limits_{i=0}^{m+1}f_i\cdot n^i\cdot \sum\limits_{d|n}\mu(d)\cdot d^{m-i}\\ &{\kern 20pt}=\sum\limits_{i=0}^{m+1}f_i\cdot n^i\cdot\prod\limits_{j=1}^{\omega}\sum\limits_{k=0}^{\alpha_j}\mu(p_j^k)\cdot p_j^{(m-i)\cdot k}\\ &{\kern 20pt}=\sum\limits_{i=0}^{m+1}f_i\cdot n^i\cdot\prod\limits_{j=1}^{\omega}\left( 1-p_j^{m-i}\right)\\ &m的范围比较小因此可以直接用拉格朗日插值求出f_i \end{aligned} \]

  • \(求\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C} \left( \frac{\operatorname{lcm}(i,j)}{\operatorname{gcd}(i,k)} \right) ^{\operatorname{gcd}(i,j,k)} \quad A,B,C\leq 10^5,T组数据,T\leq 70\)

    \[\begin{aligned} &{\kern 12pt}\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C} \left( \frac{\operatorname{lcm}(i,j)}{\operatorname{gcd}(i,k)} \right) ^{\operatorname{gcd}(i,j,k)}\\ &=\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C} \left( \frac{i\cdot j}{\operatorname{gcd}(i,k)\cdot \operatorname{gcd}(i,j)} \right) ^{\operatorname{gcd}(i,j,k)}\\ &可以拆成两个问题\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C}i^{\operatorname{gcd}(i,j,k)}以及\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C}\operatorname{gcd}(i,j)^{\operatorname{gcd}(i,j,k)}\\ &\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C}i^{\operatorname{gcd}(i,j,k)}=\prod_{i=1}^{A} i^{\sum\limits_{j=1}^B\sum\limits_{k=1}^C \operatorname{gcd}(i,j,k)}\\ &{\kern 79pt}=\prod_{i=1}^{A} i^{\sum\limits_{d=1}^{\min\left\{ i,B,C \right\} }d\sum\limits_{j=1}^{\left\lfloor \frac{B}{d} \right\rfloor}\sum\limits_{k=1}^{\left\lfloor \frac{C}{d} \right\rfloor}[\operatorname{gcd}\left( \frac{i}{d},j,k \right) =1]}\\ &{\kern 79pt}=\prod_{i=1}^{A} i^{\sum\limits_{d=1}^{\min\left\{ i,B,C \right\} }d\sum\limits_{j=1}^{\left\lfloor \frac{B}{d} \right\rfloor}\sum\limits_{k=1}^{\left\lfloor \frac{C}{d} \right\rfloor}\sum\limits_{t|\frac{i}{d},t|j,t|k}\mu(t)}\\ &{\kern 79pt}=\prod_{i=1}^{A} i^{\sum\limits_{s|i}\sum\limits_{t|s}\mu(t)\cdot \left\lfloor \frac{B}{s} \right\rfloor\cdot \left\lfloor \frac{C}{s} \right\rfloor\cdot \frac{s}{t}}\\ &这边有个小trick,\mu\ast id=\varphi\\ &\quad proof:\forall d|n,满足1\leq a\leq n且\operatorname{gcd}(a,n)=d \Leftrightarrow \operatorname{gcd}\left( \frac{a}{d},\frac{n}{d} \right) 的a一共有\varphi\left( \frac{n}{d} \right)个\\ &\qquad\qquad 故\sum\limits_{d|n}\varphi\left( \frac{n}{d} \right) =\sum\limits_{d|n}\varphi(d)=n\\ &{\kern 59pt}原式=\prod_{i=1}^{A} i^{\sum\limits_{s|i}\varphi(s)\cdot \left\lfloor \frac{B}{s} \right\rfloor\cdot \left\lfloor \frac{C}{s} \right\rfloor}\\ &{\kern 79pt}=\prod_{s=1}^{A}\prod_{i=1}^{\left\lfloor \frac{A}{s} \right\rfloor}\left( i\cdot s \right) ^{\varphi(s)\cdot \left\lfloor \frac{B}{s} \right\rfloor\cdot \left\lfloor \frac{C}{s} \right\rfloor}\\ &{\kern 79pt}=\prod_{s=1}^{A}\left[ \left( \left\lfloor \frac{A}{s} \right\rfloor \right) !\cdot s^{\left\lfloor \frac{A}{s} \right\rfloor} \right] ^{\varphi(s)\cdot \left\lfloor \frac{B}{s} \right\rfloor\cdot \left\lfloor \frac{C}{s} \right\rfloor}\\ &接下来预处理+数论分块就可以了\\ &\prod_{i=1}^{A}\prod_{j=1}^{B} \prod_{k=1}^{C}\operatorname{gcd}(i,j)^{\operatorname{gcd}(i,j,k)}=\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{i=1}^{\left\lfloor \frac{A}{d} \right\rfloor}\prod_{j=1}^{\left\lfloor \frac{B}{d} \right\rfloor} \prod_{k=1}^{\left\lfloor \frac{C}{d} \right\rfloor} [d\cdot \operatorname{gcd}(i,j)]^{d\cdot [\operatorname{gcd}(i,j,k)=1]}\\ &{\kern 110pt}= \prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{i=1}^{\left\lfloor \frac{A}{d} \right\rfloor}\prod_{j=1}^{\left\lfloor \frac{B}{d} \right\rfloor}[d\cdot \operatorname{gcd}(i,j)]^{d\cdot \sum\limits_{k=1}^{\left\lfloor \frac{C}{d} \right\rfloor}\sum\limits_{t|i,t|j,t|k}\mu(t)}\\ &{\kern 110pt}=\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{t=1}^{\min\left\{ \left\lfloor \frac{A}{d} \right\rfloor,\left\lfloor \frac{B}{d} \right\rfloor,\left\lfloor \frac{C}{d} \right\rfloor \right\} } \prod_{i=1}^{\left\lfloor \frac{A}{t\cdot d} \right\rfloor} \prod_{j=1}^{\left\lfloor \frac{B}{t\cdot d} \right\rfloor} [d\cdot t\cdot \operatorname{gcd}(i,j)]^{d\cdot \mu(t)\cdot \left\lfloor \frac{C}{t\cdot d} \right\rfloor}\\ &这个式子同样可以拆成两部分来计算,\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{t=1}^{\min\left\{ \left\lfloor \frac{A}{d} \right\rfloor,\left\lfloor \frac{B}{d} \right\rfloor,\left\lfloor \frac{C}{d} \right\rfloor \right\} } \prod_{i=1}^{\left\lfloor \frac{A}{t\cdot d} \right\rfloor} \prod_{j=1}^{\left\lfloor \frac{B}{t\cdot d} \right\rfloor} [d\cdot t]^{d\cdot \mu(t)\cdot \left\lfloor \frac{C}{t\cdot d} \right\rfloor}\\ &以及\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{t=1}^{\min\left\{ \left\lfloor \frac{A}{d} \right\rfloor,\left\lfloor \frac{B}{d} \right\rfloor,\left\lfloor \frac{C}{d} \right\rfloor \right\} } \prod_{i=1}^{\left\lfloor \frac{A}{t\cdot d} \right\rfloor} \prod_{j=1}^{\left\lfloor \frac{B}{t\cdot d} \right\rfloor} \operatorname{gcd}(i,j)^{d\cdot \mu(t)\cdot \left\lfloor \frac{C}{t\cdot d} \right\rfloor}\\ &{\kern 12pt}\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{t=1}^{\min\left\{ \left\lfloor \frac{A}{d} \right\rfloor,\left\lfloor \frac{B}{d} \right\rfloor,\left\lfloor \frac{C}{d} \right\rfloor \right\} } \prod_{i=1}^{\left\lfloor \frac{A}{t\cdot d} \right\rfloor} \prod_{j=1}^{\left\lfloor \frac{B}{t\cdot d} \right\rfloor} [d\cdot t]^{d\cdot \mu(t)\cdot \left\lfloor \frac{C}{t\cdot d} \right\rfloor}\\ &=\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{t=1}^{\min\left\{ \left\lfloor \frac{A}{d} \right\rfloor,\left\lfloor \frac{B}{d} \right\rfloor,\left\lfloor \frac{C}{d} \right\rfloor \right\} }[d\cdot t]^{d\cdot \mu(t)\cdot \left\lfloor \frac{A}{d\cdot t} \right\rfloor\cdot \left\lfloor \frac{B}{d\cdot t} \right\rfloor\cdot \left\lfloor \frac{C}{d\cdot t} \right\rfloor}\\ &=\prod_{s=1}^{\min\left\{ A,B,C \right\} } s^{\left\lfloor \frac{A}{s} \right\rfloor\cdot \left\lfloor \frac{B}{s} \right\rfloor\cdot \left\lfloor \frac{C}{s} \right\rfloor\cdot \sum\limits_{t|s}\mu(t)\cdot \frac{s}{t}}\\ &=\prod_{s=1}^{\min\left\{ A,B,C \right\} } s^{\left\lfloor \frac{A}{s} \right\rfloor\cdot \left\lfloor \frac{B}{s} \right\rfloor\cdot \left\lfloor \frac{C}{s} \right\rfloor\cdot \varphi(s)}\\ &第一个式子这样已经可以数论分块做了。\\ &{\kern 12pt}\prod_{d=1}^{\min\left\{ A,B,C \right\}}\prod_{t=1}^{\min\left\{ \left\lfloor \frac{A}{d} \right\rfloor,\left\lfloor \frac{B}{d} \right\rfloor,\left\lfloor \frac{C}{d} \right\rfloor \right\} } \prod_{i=1}^{\left\lfloor \frac{A}{t\cdot d} \right\rfloor} \prod_{j=1}^{\left\lfloor \frac{B}{t\cdot d} \right\rfloor} \operatorname{gcd}(i,j)^{d\cdot \mu(t)\cdot \left\lfloor \frac{C}{t\cdot d} \right\rfloor}\\ &=\prod_{s=1}^{\min\left\{ A,B,C \right\}}\prod_{i=1}^{\left\lfloor \frac{A}{s} \right\rfloor} \prod_{j=1}^{\left\lfloor\frac{B}{s}\right\rfloor} \operatorname{gcd}(i,j)^{\left\lfloor \frac{C}{s} \right\rfloor\cdot \varphi(s)}\\ &=\prod_{s=1}^{\min\left\{ A,B,C \right\}}\left[ \prod\limits_{d=1}^{\min\left\{ \left\lfloor \frac{A}{s} \right\rfloor,\left\lfloor \frac{B}{s} \right\rfloor \right\}}d^{\sum\limits_{i=1}^{\left\lfloor \frac{A}{s\cdot d} \right\rfloor}\sum\limits_{j=1}^{\left\lfloor \frac{B}{s\cdot d} \right\rfloor}[\operatorname{gcd}(i,j)=1]} \right]^{\varphi(s)\cdot \left\lfloor \frac{C}{s} \right\rfloor}\\ &=\prod_{s=1}^{\min\left\{ A,B,C \right\}}\left[ \prod\limits_{d=1}^{\min\left\{ \left\lfloor \frac{A}{s} \right\rfloor,\left\lfloor \frac{B}{s} \right\rfloor \right\}}d^{\sum\limits_{t=1}^{\min\left\{ \left\lfloor \frac{A}{s\cdot d} \right\rfloor,\left\lfloor \frac{B}{s\cdot d} \right\rfloor \right\} } \mu(t)\cdot \left\lfloor \frac{A}{s\cdot d\cdot t} \right\rfloor\cdot \left\lfloor \frac{B}{s\cdot d\cdot t} \right\rfloor} \right]^{\varphi(s)\cdot \left\lfloor \frac{C}{s} \right\rfloor}\\ &=\prod_{s=1}^{\min\left\{ A,B,C \right\}}\left[ \prod_{m=1}^{\min{\left\lfloor \frac{A}{s} \right\rfloor,\left\lfloor\frac{B}{s} \right\rfloor}}\left( \prod_{d|m}d^{\mu(\frac{m}{d})} \right)^{\left\lfloor \frac{A}{s\cdot m} \right\rfloor\cdot \left\lfloor \frac{B}{s\cdot m} \right\rfloor} \right]^{\varphi(s)\cdot \left\lfloor \frac{C}{s} \right\rfloor}\\ &然后我们预处理出中间的\prod_{d|m}d^{\mu(\frac{m}{d})}然后就可以数论分块套数论分块求解上面的式子了。 \end{aligned} \]

posted @ 2023-07-16 16:24  clapp  阅读(25)  评论(0编辑  收藏  举报