标签:spl time sum mes 地方 数学题 limits class its
弄模数弄了我一天,结果少模了一个地方
我们要求:\[(\sum\limits_{i=1}^n \sum\limits_{j=1}^n i\times j\times gcd(i,j))mod\ p\]
我们先不管后面的模\(p\),考虑前面枚举\(gcd(i,j)\):\[\sum\limits_{d=1}^n d \sum\limits_{i=1}^n \sum\limits_{j=1}^n i\times j\ [gcd(i,j)=d]\]
套路的除\(d\):\[\sum\limits_{d=1}^n d^3 \sum\limits_{i=1}^{\left\lfloor \frac{n}{d} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{d} \right\rfloor} i\times j\ [gcd(i,j)=1]\]
后面显然用莫比乌斯反演,我们用性质来变换:\[\sum\limits_{d=1}^n d^3 \sum\limits_{i=1}^{\left\lfloor \frac{n}{d} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{d} \right\rfloor} i\times j \sum\limits_{k|gcd(i,j)} \mu (k)\]
套路的枚举\(k\):
\[\sum\limits_{d=1}^n d \sum\limits_{k=1}^{\left\lfloor \frac{n}{d} \right\rfloor} \mu (k) \sum\limits_{i=1}^{\left\lfloor \frac{n}{d} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{d} \right\rfloor} i\times j\ [k|gcd(i,j)]\]
除\(k\)把后面去掉:\[\sum\limits_{d=1}^n d^3 \sum\limits_{k=1}^{\left\lfloor \frac{n}{d} \right\rfloor} \mu (k) k^2\sum\limits_{i=1}^{\left\lfloor \frac{n}{dk} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{dk} \right\rfloor} i\times j\]
我们用\(T=dk\)带入:\[\sum\limits_{T=1}^n \sum\limits_{d|T} d^3 \mu (\frac{T}{d}) {(\frac{T}{d})}^2\sum\limits_{i=1}^{\left\lfloor \frac{n}{T} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{T} \right\rfloor} i\times j\]
前面的\(d^3\)可以和\({(\frac{T}{d})}^2\)消去分母:\[\sum\limits_{T=1}^n \sum\limits_{d|T} d \mu (\frac{T}{d}) T^2\sum\limits_{i=1}^{\left\lfloor \frac{n}{T} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{T} \right\rfloor} i\times j\]
换个位置:\[\sum\limits_{T=1}^n T^2 \sum\limits_{d|T} d \mu (\frac{T}{d}) \sum\limits_{i=1}^{\left\lfloor \frac{n}{T} \right\rfloor} \sum\limits_{j=1}^{\left\lfloor \frac{n}{T} \right\rfloor} i\times j\]
我们设函数\(S\):\[S(n)=(\sum\limits_{i=1}^n i)^2\]
那么原式可化为:\[\sum\limits_{T=1}^n T^2 \sum\limits_{d|T} d \mu (\frac{T}{d}) S(\left\lfloor \frac{n}{T} \right\rfloor)\]
因为\(φ=id\times \mu\),所以:\[\sum\limits_{T=1}^n T^2 φ(T)\ S(\left\lfloor \frac{n}{T} \right\rfloor)\]
标签:spl time sum mes 地方 数学题 limits class its
原文地址:https://www.cnblogs.com/yexinqwq/p/11130260.html