题目大意:
求
\[\prod\limits_{i=1}^{n} \prod\limits_{j=1}^{m} f[gcd(i,j)]\]
这个\(gcd(i,j)\)肯定是要提出来的
\[\prod\limits_{d=1}^{n}\prod\limits_{i=1}^{n} \prod\limits_{j=1}^{m} [gcd(i,j)==d]*f[d]\]
把\(f[d]\)提前
\[\prod\limits_{d=1}^{n}f[d]^{\sum\limits_{i=1}^{\lfloor\frac{n}{d}\rfloor}\sum\limits_{j=1}^{\lfloor\frac{m}{d}\rfloor}[gcd(i,j)==1]}\]
先把指数单独拿出来看,会发现是很熟悉的形式,直接上莫反
\[\sum\limits_{i=1}^{\lfloor\frac{n}{d}\rfloor}\mu(i)\lfloor\frac{n}{id}\rfloor\lfloor\frac{m}{id}\rfloor\]
设\(T=id\)
\[\sum\limits_{T=1}^{\lfloor\frac{n}{d}\rfloor}\lfloor\frac{n}{T}\rfloor\lfloor\frac{n}{T}\rfloor\sum\limits_{t|T}\mu(t)\]
我们把\(T\)直接代回原式枚举
\[\prod\limits_{T=1}^{n}\prod\limits_{d|T}f(d)^{\mu(\frac{T}{d})\lfloor\frac{n}{T}\rfloor\lfloor\frac{n}{T}\rfloor}\]
把后面分成两部分
\[\prod\limits_{T=1}^{n}(\prod\limits_{d|T}f(d)^{\mu(\frac{T}{d})})^{\lfloor\frac{n}{T}\rfloor\lfloor\frac{n}{T}\rfloor}\]
后面两个\(\lfloor\frac{n}{T}\rfloor\lfloor\frac{n}{T}\rfloor\)已经可以除法分块了,前面这个怎么办呢
观察到\(n<=1e6\),后面这个只要用埃筛暴力求前缀积就好了,根据调和级数,复杂度为\(O(nlogn)\)