瞎jb推一波式子,推出
[ans=n^{x+y}sum_{j=0}^{y+1}a_jsum_{i|n}sum_{d_1|n/i}i^{j-x}d_1^{y-x}mu(d_1)
]
其中 (a_j) 是自然数幂和的多项式系数。
然后后面显然是个积性函数,随便求求就好了。
- 推导
[egin{aligned}
frac{ans}{n^y}&=sum_{dmid n}d^{x-y}sum_{i=1}^{n}[gcd(i,n)=d]i^y\
&=sum_{dmid n}d^{x-y}sum_{j=1}^{n/d}[gcd(j,n/d)=1](jd)^y\
&=sum_{dmid n}d^{x}sum_{j=1}^{n/d}[gcd(j,n/d)=1]j^y\
&=sum_{dmid n}d^{x}f(n/d)\
end{aligned}
]
[egin{aligned}
f(n)&=sum_{i=1}^{n}[gcd(i,n)=1]i^y\
&=sum_{d|n}mu(d)d^ysum_{i=1}^{n/d}i^y
end{aligned}
]
[egin{aligned}
ans&=n^ysum_{d_1mid n}d_1^{x}sum_{d_2mid n/d_1}mu(d_2)d_2^ysum_{i=1}^{n/d_1/d_2}i^y\
end{aligned}
]
[frac{ans}{n^y}=sum_{i|n}^{n}g(i,y)sum_{d1 imes d2=n/i}d_1^xmu(d_2)d_2^y=sum_{i|n}sum_{j=0}^{y}a_ji^jsum_{d_1|n/i}^{n/i}(n/i/d_1)^xmu(d_1)d_1^y=sum_{j=0}^{y}a_jsum_{i|n}i^jsum_{d_1|n/i}frac{n^x}{(id_1)^x}mu(d_1)d_1^y
]
[g(n,k)=sum_{i|n}sum_{j|n/i}i^{k-x}j^{y-x}mu(j)\
g(p^c, k)=sum_{i|p^c}sum_{j|p^c/i}j^{k-x}mu(i)i^{y-x}=sum_{i|p^c}i^{k-x}-p^{y-x}sum_{i|p^{c-1}}i^{k-i}
]