不妨假设 \(n < m\)。
\[\begin{aligned}
\sum_{i = 1}^n\sum_{j = 1}^m\dfrac{ij}{\gcd(i, j)} &= \sum_{d = 1}^n\sum_{i = 1}^n\sum_{j = 1}^m[\gcd(i, j) = d]\dfrac{ij}{d}\\
\\
&= \sum_{d = 1}^n\sum_{i = 1}^{\lfloor\frac{n}{d}\rfloor}\sum_{j = 1}^{\lfloor\frac{m}{d}\rfloor}[\gcd(i, j) = 1]ijd\\
\\
&= \sum_{d = 1}^n\sum_{i = 1}^{\lfloor\frac{n}{d}\rfloor}\sum_{j = 1}^{\lfloor\frac{m}{d}\rfloor}ijd\sum_{k \mid \gcd(i, j)}\mu(k)\\
\\
&= \sum_{d = 1}^n\sum_{k = 1}^{\lfloor\frac{n}{d}\rfloor}\mu(k)\cdot k^2\sum_{i = 1}^{\lfloor\frac{n}{dk}\rfloor}i\sum_{j = 1}^{\lfloor\frac{m}{dk}\rfloor}jd\\
\end{aligned}
\]
定义 \(f(n) = \sum_{i = 1}^ni\)。
枚举 \(T = dk\)。
\[\begin{aligned}
&= \sum_{d = 1}^n\sum_{k = 1}^{\lfloor\frac{n}{d}\rfloor}\mu(k)\cdot k^2f(\lfloor\frac{n}{dk}\rfloor)\cdot f(\lfloor\frac{m}{dk}\rfloor)\cdot d\\
\\
&= \sum_{T = 1}^{n}f(\lfloor\dfrac{n}{T}\rfloor)\cdot f(\lfloor\dfrac{m}{T}\rfloor)\cdot \sum_{d \mid T}\mu(\dfrac{T}{d})\cdot (\dfrac{T}{d})^2 \cdot d\\
\\
&= \sum_{T = 1}^{n}f(\lfloor\dfrac{n}{T}\rfloor)\cdot f(\lfloor\dfrac{m}{T}\rfloor)\cdot \sum_{d \mid T}\mu(d)\cdot d \cdot T\\
\end{aligned}
\]
数论函数的积性在卷积中封闭。
由于 \(g(T) = \mu(T) \cdot T\) 是积性函数(\(id\) 完全积性,显然成立),那么 \(F(T) = \sum_{d \mid T}\mu(d)\cdot d = g * 1\) 也是积性函数。
即求
\[\sum_{T = 1}^{n}f(\lfloor\dfrac{n}{T}\rfloor)\cdot f(\lfloor\dfrac{m}{T}\rfloor)\cdot T\cdot F(T)\\
\]
可以线性筛预处理 \(T \cdot F(T)\) 的前缀和,然后数论分块。(对于函数 \(F\),任意质数的幂次 \(F(p^k) = 1 - p\))
有结论
\[d(ij) = \sum_{x \mid i}\sum_{y\mid j}[\gcd(x, y) = 1]
\]
假定 \(i = p_1^{a_1}p_2^{a_2}\cdots p_k^{a_k}, \ j = p_1^{b_1}p_2^{b_2}\cdots p_k^{b_k}\)。
任意一个素数因子对答案贡献的形式是相同的,单独考虑一个 \(p_c\),则答案一定可以写成 \(f(p_c) \cdot X\)。
左边:\(f(p_c) = a_c + b_c + 1\)。
右边:用一个数对表示 \(p_c\) 在 \(x\) 和 \(y\) 中出现的幂次,形如 \((\alpha, 0)\) 或 \((0, \beta)\) 的合法,则合法数对数即 \(f(p_c) = a_c + b_c + 1\)。
左边等于右边。
利用上述公式推导:
\[\begin{aligned}
\sum_{i = 1}^n\sum_{j = 1}^md(ij)
&= \sum_{i = 1}^n\sum_{j = 1}^m\sum_{x \mid i}\sum_{y\mid j}[\gcd(x, y) = 1]\\
\\
&= \sum_{x = 1}^n\sum_{y = 1}^m\lfloor\dfrac{n}{x}\rfloor\lfloor\dfrac{m}{y}\rfloor \cdot [\gcd(x, y) = 1]\\
\\
&= \sum_{x = 1}^n\sum_{y = 1}^m\lfloor\dfrac{n}{x}\rfloor\lfloor\dfrac{m}{y}\rfloor \cdot \sum_{k \mid \gcd(x, y)}\mu(k)\\
\\
&= \sum_{k = 1}^n\mu(k)\sum_{i = 1}^{\lfloor\frac{n}{k}\rfloor}\lfloor\dfrac{n}{ik}\rfloor\cdot \sum_{j = 1}^{\lfloor\frac{m}{k}\rfloor}\lfloor\dfrac{m}{jk}\rfloor\\
\end{aligned}
\]
记 \(f(n) = \sum_{i = 1}^n\lfloor\dfrac{n}{i}\rfloor\)。
由于
\[\lfloor\dfrac{n}{ik}\rfloor = \lfloor\dfrac{\lfloor\dfrac{n}{k}\rfloor}{i}\rfloor
\]
即求
\[\sum_{k = 1}^n\mu(k)\cdot f(\lfloor\frac{n}{k}\rfloor)\cdot f(\lfloor\frac{m}{k}\rfloor)
\]
后面两项可以 \(O(N\sqrt N)\) 预处理,也可以加个记忆化在线算。
设完全积性函数:\(g(n) = n^k\)。
\[\begin{aligned}
&=\sum_{i = 1}^n\sum_{j = 1}^ng(i + j)\gcd(i, j)\cdot \mu^2(\gcd(i, j))\\
\\
&= \sum_{d = 1}^nd\cdot g(d)\mu^2(d)\sum_{i = 1}^{n/d}\sum_{j = 1}^{n/d}[(i, j) =1]g(i + j)\\
\\
&= \sum_{d = 1}^nd\cdot g(d)\mu^2(d)\sum_{x = 1}^{n/d}\mu(x)g(x)\sum_{i = 1}^{n/d/x}\sum_{j = 1}^{n/d/x}g(i + j)\\
\end{aligned}
\]
设 \(S(n) = \sum\limits_{i = 1}^n\sum\limits_{j = 1}^ng(i + j)\),枚举 \(T = xd\)。
\[\begin{aligned}
&= \sum_{d = 1}^nd\cdot g(d)\mu^2(d)\sum_{x = 1}^{n/d}\mu(x)g(x)S(n/T)\\
\\
&= \sum_{T = 1}^nS(n/T)\sum_{d \mid T}^nd\cdot g(d)\mu^2(d)\mu(\dfrac{T}{d})g(\dfrac{T}{d})\\
\\
&= \sum_{T = 1}^n S(n/T)\cdot g(T)\sum_{d \mid T}^nd\cdot \mu^2(d)\mu(\dfrac{T}{d})\\
\end{aligned}
\]
\(F(n) = \sum_{d \mid n}d\cdot \mu^2(d)\mu(\dfrac{n}{d})\) 一定是积性函数,满足:
\[F(p^c) =
\begin{cases}
p - 1 & c = 1\\
\\
-p & c = 2\\
\\
0& c \ge 3
\end{cases}
\]
对于 \(S\),有递推式:
\[\begin{aligned}
S(n)
&= S(n - 1) + \sum_{i = 1}^{n - 1}g(n + i) + \sum_{j = 1}^{n - 1}g(n + j) + g(2n)\\
\\
&= S(n - 1) + sum_g(2n) + sum_g(2n - 1) - 2\times g(n)\\
\end{aligned}
\]
最后即求
\[\sum_{T = 1}^n g(T)F(T)\cdot S(n/T)
\]
所有预处理皆可以 \(O(n)\) 做完,查询 \(O(\sqrt n)\)。
\[\begin{aligned}
\prod_{i = 1}^n\prod_{j = 1}^n \dfrac{ij}{\gcd(i, j)^2} = \prod_{i = 1}^n\prod_{j = 1}^n ij\times (\prod_{i = 1}^n\prod_{j = 1}^n \gcd(i, j))^{-2}
\end{aligned}
\]
前一部分:
\[\prod_{i = 1}^n\prod_{j = 1}^n ij = \prod_{i = 1}^ni^n n! = (n!)^{2n}
\]
后一部分:
\[\begin{aligned}
\prod_{i = 1}^n\prod_{j = 1}^n \gcd(i, j)
&= \prod_{d = 1}^n d^{\large\sum_{i = 1}^n\sum_{j = 1}^n[\gcd(i,j) = d]}\\
\\
&= \prod_{d = 1}^n d^{\large\sum_{i = 1}^{n/d}\sum_{j = 1}^{n/d}[\gcd(i,j) = 1]}\\
\\
&= \prod_{d = 1}^n d^{\large 2 \cdot sum_{\varphi}(n/d) - 1}\\
\end{aligned}
\]
\(\varphi\) 的前缀和会爆 int
,计算时模 MOD - 1
。
令 \(n < m\)。
\[\begin{aligned}
\prod_{i = 1}^n\prod_{j = 1}^mf_{\gcd(i, j)}
&= \prod_{d = 1}^nf_d^{\sum_{i = 1}^{n/d}\sum_{j = 1}^{m/d}[\gcd(i, j) = 1]}\\
\\
&= \prod_{d = 1}^nf_d^{\sum_{k = 1}^{n/d}\mu(k)\lfloor\frac{n}{dk}\rfloor\lfloor\frac{m}{dk}\rfloor} \\
\\
&= \prod_{T = 1}^n\prod_{d \mid T}f_d^{\mu(T/d)\lfloor\frac{n}{dk}\rfloor\lfloor\frac{m}{dk}\rfloor} \\
\\
&= \prod_{T = 1}^n(\prod_{d \mid T}f_d^{\mu(T/d)})^{\lfloor\frac{n}{dk}\rfloor\lfloor\frac{m}{dk}\rfloor} \\
\end{aligned}
\]
中间的东西暴力预处理,复杂度调和级数再带个快速幂。
首先有结论
\[d(ijk) = \sum_{x \mid i}\sum_{y\mid j}\sum_{z\mid k}[\gcd(x, y) = 1][\gcd(x, z) = 1][\gcd(y, z) = 1]
\]
证明过程与 P3327 [SDOI2015] 约数个数和 如出一辙。
Part1 反演
\[\begin{aligned}
&= \sum_{i = 1}^A\sum_{j = 1}^B\sum_{k = 1}^C\sum_{x \mid i}\sum_{y\mid j}\sum_{z\mid k}[\gcd(x, y) = 1][\gcd(x, z) = 1][\gcd(y, z) = 1]\\
\\
&= \sum_{x = 1}^A\sum_{y = 1}^B\sum_{z = 1}^C[\gcd(x, y) = 1][\gcd(x, z) = 1][\gcd(y, z) = 1]\lfloor\dfrac{A}{x}\rfloor\lfloor\dfrac{B}{y}\rfloor\lfloor\dfrac{C}{z}\rfloor\\
\\
&= \sum_{x = 1}^A\sum_{y = 1}^B\sum_{z =1}^C\lfloor\dfrac{A}{x}\rfloor\lfloor\dfrac{B}{y}\rfloor\lfloor\dfrac{C}{z}\rfloor\sum_{u \mid \gcd(x, y)}\mu(u)\sum_{v \mid\gcd(x, z)}\mu(v)\sum_{w \mid \gcd(y,z)}\mu(w)\\
\\
&= \sum_{u = 1}^{\min(A, B)}\sum_{v = 1}^{\min(A, C)}\sum_{w = 1}^{\min(B, C)}\mu(u)\mu(v)\mu(w)\sum_{\operatorname{lcm}(u, v)\mid x}\lfloor\dfrac{A}{x}\rfloor\sum_{\operatorname{lcm}(u, w)\mid y}\lfloor\dfrac{B}{y}\rfloor\sum_{\operatorname{lcm}(v, w)\mid z}\lfloor\dfrac{C}{z}\rfloor\\
\end{aligned}
\]
记 \(f_x(d) = \sum_{d \mid n}\dfrac{x}{n}\)。
则上式分别写成 \(f_A(\operatorname{lcm}(u, v)), \ f_B(\operatorname{lcm}(u, w)), f_C(\operatorname{lcm}(v, w))\),可以 \(O(n\ln n)\) 预处理。
至此,复杂度 \(O(n^3)\),与暴力无异。
Part2 优化
任意 \(\mu\) 不为 \(0\)。
任意 \(f_x(d)\) 不为 \(0\),即 \(d \le x\)。
如果能跳过不满足上述条件的情况,复杂度会大幅下降。
建图。
如果 \(u, v\) 满足 \(\mu(u) \ne 0 \land \mu(v) \ne 0\) 且 \(\operatorname{lcm}(u, v) \le \max(A, B,C)\),则 \(u, v\) 有可能对答案产生贡献,连无向边。
新图中的一个三元环对应一对合法的 \((u, v, w)\)。
满足条件的边数 \(m\) 很小。
借用 P1989 无向图三元环计数 的思路可以 \(O(m\sqrt m)\) 内找到每个环。
对于每个环,依次统计 \(6\) 种排列顺序对答案的贡献。
当然,上述过程只适用于 \(u, v, w\) 两两不同的情况,对于两个元素相同或全相同的情况拎出来枚举即可。
朴素的建图是 \(O(n^3)\) 的。
枚举 \(g\),将满足 \(\gcd(u, v) = g \land \mu(u) \ne 0 \land\mu(v) \ne 0 \land\operatorname{lcm}(u, v) < \max V\) 的点对连边(无序)。
trick:统计 \((u, v, w)\) 贡献时,把上界统一设成 \(\max V\) 即可,如果 \(u > \min(A, B)\),则 \(f_A([u, v]), \ f_B([u, w])\) 至少一项为 \(0\)。
#include<bits/stdc++.h>
#define ll long long
#define pb emplace_back
using namespace std;
constexpr int N = 1e5, P = 1e9 + 7;
int p[N], v[N + 5], idx, mu[N + 5];
void init() {
mu[1] = 1;
for(int i = 2; i <= N; ++ i) {
if(v[i] == 0) {
p[++ idx] = i;
mu[i] = -1;
}
for(int j = 1; j <= idx && p[j] <= N / i; ++ j) {
v[i * p[j]] = 1;
if(i % p[j] == 0) {
mu[i * p[j]] = 0;
break;
}
mu[i * p[j]] = -mu[i];
}
}
}
int A, B, C, MX, MI, d[N + 5];
ll fa[N + 5], fb[N + 5], fc[N + 5], st[N + 5];
struct Node {
int u, v, w;
} e[N << 3];
vector<pair<int, int>> G[N + 5];
void solve() {
cin >> A >> B >> C, MX = max({A, B, C}), MI = min({A, B, C});
memset(fa + 1, 0, MX * 8 + 8), memset(fb + 1, 0, MX * 8 + 8);
memset(fc + 1, 0, MX * 8 + 8);
for(int i = 1; i <= A; ++ i) for(int j = i; j <= A; j += i) fa[i] += A / j;
for(int i = 1; i <= B; ++ i) for(int j = i; j <= B; j += i) fb[i] += B / j;
for(int i = 1; i <= C; ++ i) for(int j = i; j <= C; j += i) fc[i] += C / j;
ll ans = 0;
// u = v = w
for(int i = 1; i <= MI; ++ i) {
if(mu[i]) (ans += mu[i] /** mu[i] * mu[i]*/ * fa[i] * fb[i] % P * fc[i]) %= P;
}
// 建图 + 有两个点相同
for(int i = 1; i <= MX; ++ i) G[i].clear(); memset(d + 1, 0, MX * 4 + 4), idx = 0;
for(int g = 1; g <= MX; ++ g) {
for(int i = 1; i <= MX / g; ++ i) if(mu[i * g]) {
for(int j = i + 1; j <= MX / g / i; ++ j) if(mu[j * g] && __gcd(i, j) == 1) {
int u = i * g, v = j * g, Lcm = i * j * g;
ans += mu[u] * mu[u] * mu[v] * (fa[u] * fb[Lcm] * fc[Lcm] + fa[Lcm] * fb[u] * fc[Lcm] + fa[Lcm] * fb[Lcm] * fc[u]);
ans += mu[v] * mu[v] * mu[u] * (fa[v] * fb[Lcm] * fc[Lcm] + fa[Lcm] * fb[v] * fc[Lcm] + fa[Lcm] * fb[Lcm] * fc[v]);
e[++ idx] = {u, v, Lcm}, ++ d[u], ++ d[v];
}
}
}
for(int i = 1; i <= idx; ++ i) {
auto [u, v, w] = e[i];
if(d[u] > d[v] || (d[u] == d[v] && u > v)) G[u].pb(v, w);
if(d[u] < d[v] || (d[u] == d[v] && u < v)) G[v].pb(u, w);
}
for(int u = 1; u <= MX; ++ u) {
for(auto [v, lcm1] : G[u]) st[v] = lcm1;
for(auto [v, lcm1] : G[u]) {
for(auto [w, lcm2] : G[v]) if(st[w]) {
int lcm3 = st[w], uvw = mu[u] * mu[v] * mu[w];
ans += uvw * (fa[lcm1] * fb[lcm2] * fc[lcm3]
+ fa[lcm1] * fb[lcm3] * fc[lcm2]
+ fa[lcm2] * fb[lcm1] * fc[lcm3]
+ fa[lcm2] * fb[lcm3] * fc[lcm1]
+ fa[lcm3] * fb[lcm1] * fc[lcm2]
+ fa[lcm3] * fb[lcm2] * fc[lcm1]);
}
}
for(auto [v, lcm1] : G[u]) st[v] = 0;
}
cout << (ans % P + P) % P << '\n';
}
int main() {
cin.tie(0)->sync_with_stdio(0);
init();
int T;
cin >> T;
while(T --) {
solve();
}
return 0;
}
Type0
\[\begin{aligned}
P_0(A, B, C)
&= \prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C \dfrac{\operatorname{lcm}(i, j)}{\gcd(i, k)}\\
\\
&= \prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C \dfrac{ij}{\gcd(i, j)\gcd(i, k)}\\
\end{aligned}
\]
第一部分:
\[\begin{aligned}
\prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C ij &= \prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C i \cdot \prod_{j = 1}^B\prod_{i = 1}^A\prod_{k = 1}^C j\\
\\
&= (\prod_{i = 1}^{A}i)^{BC} \cdot (\prod_{j = 1}^{B}j)^{AC}\\
\\
&= (A!)^{BC}\cdot (B!)^{AC}
\end{aligned}
\]
预处理 \(1\) 到 \(N\) 的阶乘。
第二部分:
\[\begin{aligned}
\prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C \gcd(i, j)\gcd(i, k) &= [\prod_{i = 1}^A\prod_{j = 1}^B \gcd(i, j)]^C \cdot [\prod_{i = 1}^A\prod_{k = 1}^C \gcd(i, k)]^B\\
\\
&= \text{calc}_0(A, B)^C\cdot \text{calc}_0(A, C)^B
\end{aligned}
\]
其中
\[\begin{aligned}
\text{calc}_0(n, m)
&= \prod_{i = 1}^n\prod_{j = 1}^m \gcd(i, j)\\
\\
&= \prod_{d = 1}^{\min(n, m)}d^{\large\sum_{i = 1}^{n/d}\sum_{j = 1}^{m/d} [\gcd(i, j) = 1]}\\
\\
&= \prod_{d = 1}^{\min(n, m)}d^{\large\sum_{k = 1}^{\min(n, m) / d}\mu(k)\lfloor\frac{n}{dk}\rfloor\lfloor\frac{m}{dk}\rfloor}\\
\\
&= \prod_{T = 1}^{\min(n, m)}\prod_{d \mid T}d^{\large\mu(\frac{T}{d})\lfloor\frac{n}{T}\rfloor\lfloor\frac{m}{T}\rfloor}\\
\end{aligned}
\]
记 \(F_0(T) = \prod_{d \mid T} d^{\mu(\frac{T}{d})}\)。
则
\[\begin{aligned}
\text{calc}_0(n, m)= \prod_{T = 1}^{\min(n, m)}F_0(T)^{\lfloor\frac{n}{T}\rfloor\lfloor\frac{m}{T}\rfloor}\\
\end{aligned}
\]
\(O(n\log n)\) 预处理 \(F_0\) 前缀积及前缀积的逆元,\(O(\sqrt n \log n)\) 数论分块。
Type1
\[\begin{aligned}
P_1(A, B, C) = \prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C [\dfrac{ij}{\gcd(i, j)\gcd(i, k)}]^{ijk}\\
\end{aligned}
\]
第一部分:
\[\begin{aligned}
\prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C i^{ijk} &= \prod_{i = 1}^A\prod_{j = 1}^Bi^{ij(\sum_{k = 1}^Ck)}\\
\\
&= [\prod_{i = 1}^Ai^i]^{(\sum_{j = 1}^Bj)(\sum_{k = 1}^Ck)}\\
\end{aligned}
\]
记 \(f(n) = \sum_{i = 1}^ni\)。
\[\prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C {ij}^{ijk} =[\prod_{i = 1}^Ai^i]^{f(B)f(C)} \cdot [\prod_{i = 1}^Bi^i]^{f(A)f(C)}
\]
预处理 \(i^i\) 的前缀积。
第二部分:
\[\begin{aligned}
\prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C \gcd(i, j)^{ijk}
&= \prod_{i = 1}^A\prod_{j = 1}^B[ \gcd(i, j)^{ij}]^{f(c)}\\
\\
&= \text{calc}_1(A, B)^{f(C)}
\end{aligned}
\]
其中
\[\begin{aligned}
\text{calc}_1(n, m)
&= \prod_{i = 1}^n\prod_{j = 1}^m \gcd(i, j)^{ij}\\
\\
&= \prod_{d = 1}^{\min(n, m)}d^{\large d^2\sum_{i = 1}^{n/d}\sum_{j = 1}^{m/d} [\gcd(i, j) = 1]ij}\\
\\
&= \prod_{d = 1}^{\min(n, m)}d^{\large d^2\sum_{k = 1}^{\min(n, m) / d}k^2\mu(k)f(\lfloor\frac{n}{dk}\rfloor)f(\lfloor\frac{m}{dk}\rfloor})\\
\\
&= \prod_{T = 1}^{\min(n, m)}\prod_{d \mid T}d^{\large\mu(\frac{T}{d})T^2f(\lfloor\frac{n}{T}\rfloor)f(\lfloor\frac{m}{T}\rfloor)}\\
\end{aligned}
\]
记 \(F_1(T) = \prod_{d \mid T} d^{\mu(\frac{T}{d})T^2} = F_0(T)^T\)。
则
\[\begin{aligned}
\text{calc}_1(n, m)= \prod_{T = 1}^{\min(n, m)}F_1(T)^{f(\lfloor\frac{n}{T}\rfloor)f(\lfloor\frac{m}{T}\rfloor)}\\
\end{aligned}
\]
Type2
\[\begin{aligned}
P_2(A, B, C) = \prod_{i = 1}^A\prod_{j = 1}^B\prod_{k = 1}^C [\dfrac{\text{lcm}(i, j)}{\gcd(i, k)}]^{\gcd(i, j, k)}\\
\end{aligned}
\]
两边取对。
\[\begin{aligned}
\ln P_2(A, B, C)
&= \sum_{i = 1}^A\sum_{j = 1}^B\sum_{k = 1}^C \gcd(i, j, k)\ln\dfrac{\text{lcm}(i, j)}{\gcd(i, k)}\\
\\
&= \sum_{i = 1}^A\sum_{j = 1}^B\sum_{k = 1}^C \sum_{d\mid \gcd(i, j, k)}\varphi(d)\ln\dfrac{\text{lcm}(i, j)}{\gcd(i, k)}\\
\\
&= \sum_{d = 1}^{\min(A, B, C)}\varphi(d)\sum_{i = 1}^{A/d}\sum_{j = 1}^{B/d}\sum_{k = 1}^{C/d} \ln\dfrac{\text{lcm}(id, jd)}{\gcd(id, kd)}\\
\end{aligned}
\]
两边 \(\exp\)。
\[\begin{aligned}
P_2(A, B, C)
&= \prod_{d = 1}^{\min(A, B, C)}[\prod_{i = 1}^{A/d}\prod_{j = 1}^{B/d}\prod_{k = 1}^{C/d} \dfrac{\text{lcm}(i, j)}
{\gcd(i, k)}]^{\varphi(d)}\\
\\
&= \prod_{d = 1}^{\min(A, B, C)}P_0(\lfloor\frac{A}{d}\rfloor, \lfloor\frac{B}{d}\rfloor, \lfloor\frac{C}{d}\rfloor)^{\varphi(d)}\\
\end{aligned}
\]
本题卡常,应当把能预处理的逆元都预处理了。