⑤(BZOJ 3560)
$Sigma_{i_1|a_1}Sigma_{i_2|a_2}Sigma_{i_3|a_3}Sigma_{i_4|a_4}...Sigma_{i_n|a_n}phi(i_1i_2i_3i_4...i_n)$
$phi()$是积性函数
$phi(p^k)=p^{k-1}*(p-1)$
设当前质数为p,对于第i个数,假设它分解质因数后p的次数为ai,那么p的答案就是
$[(1+p^1+...+p^{a1})(1+p^1+...+p^{a2})...(1+p^1+...+p^{an})-1]frac{p-1}{p}+1$
乘起来就好了.....
$Sigma_{i=1}^nSigma_{j=1}^mlcm(i,j)^{gcd(i,j)}$
$=Sigma_{i=1}^nSigma_{j=1}^m (frac{i*j}{gcd(i,j)})^{gcd(i,j)}$
枚举gcd(i,j)=d
$=Sigma_{d=1}^nSigma_{i=1}^{lfloor frac{n}{d}
floor}Sigma_{j=1}^{lfloor frac{m}{d}
floor}(d*i*j)^d*(gcd(i,j)==1)$
$=Sigma_{d=1}^nSigma_{i=1}^{lfloor frac{n}{d}
floor}Sigma_{j=1}^{lfloor frac{m}{d}
floor}Sigma_{k|i且k|j}(d*i*j)^d$
$=Sigma_{d=1}^nd^dSigma_{t=1}^{lfloorfrac{n}{d}
floor}mu(t)[Sigma_{i=1}^{lfloorfrac{n}{dt}
floor}(it)^dSigma_{j=1}^{lfloorfrac{m}{dt}
floor}(jt)^d]$
$=Sigma_{d=1}^nd^dSigma_{t=1}^{lfloorfrac{n}{d}
floor}mu(t)*t^{2d}[Sigma_{i=1}^{lfloorfrac{n}{dt}
floor}i^dSigma_{j=1}^{lfloorfrac{m}{dt}
floor}j^d]$
$Sigma _{i=1}^nSigma _{j=1}^imu(lcm(i,j)^{gcd(i,j)})$
$=Sigma_{k=1}^nSigma_{i=1}^{lfloorfrac{n}{k}
floor}Sigma_{j=1}^imu((ijk)^{k}*gcd(i,j)==1)$
$∵$k>1时 $mu(x^k)=0$
$∴ =Sigma_{i=1}^nSigma_{j=1}^imu(ij)*e(gcd(i,j))$
$∵gcd(i,j)==1$
$∴mu(ij)=mu(i)*mu(j)$
$=Sigma_{i=1}^nmu(i)*Sigma_{j=1}^imu(j)*Sigma_{k|i且k|j}mu(k)$
$=Sigma_{i=1}^nmu(i)*Sigma_{k|i}mu(k)Sigma_{j=1}^{lfloorfrac{i}{k}
floor}mu(jk)$
$mu(i)≠0$时 再枚举k是i的约数 发现数量只有$5*10^7$
复杂度变成了
什么复杂度
O(能过)就好了...