$$
\begin {aligned}
\prod _ {i = 1} ^ n \prod _ {j = 1} ^ m \mathrm {lcm} (i, j) ^ {\mathrm {lcm} (i, j)} & = \prod _ {i = 1} ^ n \prod _ {j = 1} ^ m (\frac {ij} {(i, j)}) ^ {\frac {ij} {(i, j)}} \\
& = \prod _ {d = 1} ^ n \prod _ {i = 1} ^ n \prod _ {j = 1} ^ m (\frac {ij} d) ^ {\frac {ij} d [(i, j) = d]} \\
& = \prod _ {d = 1} ^ n \prod _ {i = 1} ^ {\lfloor \frac n d \rfloor } \prod _ {j = 1} ^ {\lfloor \frac m d \rfloor } (ijd) ^ {ijd [(i, j) = 1]} \\
& = \prod _ {d = 1} ^ n \prod _ {i = 1} ^ {\lfloor \frac n d \rfloor } \prod _ {j = 1} ^ {\lfloor \frac m d \rfloor } (ijd) ^ {ijd \sum _ {k | (i, j)} \mu(k)} \\
& = \prod _ {d = 1} ^ n \prod _ {k = 1} ^ n \prod _ {i = 1} ^ {\lfloor \frac n {kd} \rfloor } \prod _ {j = 1} ^ {\lfloor \frac m {kd} \rfloor } (ijdk ^ 2) ^ {ijdk ^ 2 \mu(k)} \\
& = \prod _ {T = 1} ^ n \prod _ {k | T} \prod _ {i = 1} ^ {\lfloor \frac n T \rfloor } \prod _ {j = 1} ^ {\lfloor \frac m T \rfloor } (ijTk) ^ {ijTk \mu(k)} \\
& = \prod _ {T = 1} ^ n (\prod _ {i = 1} ^ {\lfloor \frac n T \rfloor } \prod _ {j = 1} ^ {\lfloor \frac m T \rfloor } (ij) ^ {ijT\sum _ {k | T} k\mu(k)}) (T ^ {\sum _ {k | T} \mu(k)} \prod _ {k | T} k ^ {k \mu(k)}) ^ {T\sum _ {i = 1} ^ {\lfloor \frac n T \rfloor } \sum _ {j = 1} ^ {\lfloor \frac m T \rfloor }}
\end {aligned}
$$
记 $f _ n = \sum _ {i = 1} ^ n i ^ i$ ,$s _ n = \sum _ {i = 1} ^ n i$ 。$c(n, m) = \prod _ {i = 1} ^ n \prod _ {j = 1} ^ m (ij) ^ {ij} = \prod _ {i = 1} ^ n \prod _ {j = 1} ^ m (i ^ i) ^ j (j ^ j) ^ i = (\prod _ {i = 1} ^ n (i ^ i) ^ {s _ m}) (\prod _ {i = 1} ^ m (i ^ i) ^ {s _ n}) = f _ n ^ {s _ m} f _ m ^ {s _ n} $ 。
那么原式有:
$$
\prod _ {T = 1} ^ n c(\lfloor \frac n T \rfloor, \lfloor \frac m T \rfloor) ^ {T\sum _ {k | T} k\mu(k)} (T ^ {\sum _ {k | T} \mu(k)} \prod _ {k | T} k ^ {k \mu(k)}) ^ {T s _ {\lfloor \frac n T \rfloor } s _ {\lfloor \frac m T \rfloor }}
$$
剩下的 $T\sum _ {k | T} k\mu(k), (T ^ {\sum _ {k | T} \mu(k)} \prod _ {k | T} k ^ {k \mu(k)}) ^ T$ 是关于 $T$ 的式子,可以在 $O(n\ln n)$ 的时间内预处理,前缀和、前缀积,数论分块。
复杂度 $O(n \ln n + T \sqrt n \log p)$ 。
查看代码
1 |
|