JZPKIL

 题意描述:求 \(\sum\limits_{i=1}^n lcm(i,n)^ygcd(i,n)^x\)

 数据范围:\(1\le n \le 1e18,1\le x,y\le 3000\)

大神题啊

先来一波反演
\[\begin{aligned} &\ \ \ \ \sum_{i=1}^nlcm(i,n)^y\ gcd(i,n)^x\\ &=\sum_{i=1}^ngcd(i,n)^x\ (\frac{in}{gcd(i,n)})^y\\ &=\sum_{i=1}^n gcd(i,n)^{x-y}\ i^y \ n^y\\ &=n^y\sum_{i=1}^n gcd(i,n)^{x-y}\ i^y\\ &=n^y\sum_{d|n}d^{x-y}\sum_{i=1}^{\frac{n}{d}}[gcd(i,\frac{n}{d})==1](id)^y\\ &=n^y\sum_{d|n}d^x\sum_{i=1}^{\frac{n}{d}}[gcd(i,\frac{n}{d})==1]i^y\\ &=n^y\sum_{d|n}d^x\sum_{i=1}^{\frac{n}{d}}i^y\sum_{p|gcd(i,\frac{n}{d})}\mu(p)\\ &=n^y\sum_{d|n}d^x\sum_{p|\frac{n}{d}}\mu(p) \ p^y\sum_{i=1}^{\frac{n}{dp}}i^y \end{aligned}\]
反演也就这些了,接下来代入伯努力数
\[\sum\limits_{i=1}^n i^k=\frac{1}{k+1}\sum\limits_{i=1}^k \binom{k+1}{i} B_i n^{k-i+1}\]
继续化柿子
\[\begin{aligned} &\ \ \ \ \ n^y\sum_{d|n}d^x\sum_{p|\frac{n}{d}}\mu(p)\ p^y\sum_{i=1}^{\frac{n}{dp}}i^y\\ &=n^y\sum_{d|n}d^x\sum_{p|\frac{n}{d}}\mu(p)\ p^y\frac{1}{y+1}\sum_{i=1}^y\binom{y+1}{i}B_i(\frac{n}{pd})^{y-i+1}\\ &=\frac{1}{y+1}\sum_{i=1}^y\binom{y+1}{i}B_i \ n^y\sum_{d|n}d^x\sum_{p|\frac{n}{d}}\mu(p)\ p^y (\frac{n}{pd})^{y-i+1} \end{aligned}\]
\(f(n,i)=n^y\sum\limits_{d|n}d^x\sum\limits_{p|\frac{n}{d}}\mu(p)\ p^y (\frac{n}{dp})^{y-i+1}\)
发现后面这个 \(f(n,i)\) 对于每个 \(n\) 的质因子互不干扰,是个积性函数

现在只需要求出每个 \(f(p_k^{e_k},i)\) ,乘起来就行了

观察发现当且仅当 \(p=1\)\(p=p_k\) 时柿子有意义

\(N=p_k^{e_k}\)

那么 \(f(N,i)=N^y\sum\limits_{d|n}d^x((\frac{N}{d})^{y-i+1}-p_k^{y}(\frac{N}{p_kd})^{y-i+1})\)

质因子分解需要 \(Pollard\)_\(Rho\)

你可能感兴趣的:(JZPKIL)