[51 Nod 1584] 加权约数和

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Ike940067893/article/details/85042174

题意

i = 1 N j = 1 N m a x ( i , j ) σ 1 ( i j ) \large \sum_{i=1}^N\sum_{j=1}^Nmax(i,j)\cdot\sigma_1(ij)
其中
1 N 1 0 6 1\le N\le10^6
1 T 5 1 0 4 1\le T\le5\cdot10^4
σ 1 ( n ) \sigma_1(n) 表示 n n 的约数和

题目分析

A = i = 1 n j = 1 i i σ 1 ( i j ) , B = i = 1 n i σ 1 ( i 2 ) A=\sum_{i=1}^n\sum_{j=1}^ii\cdot\sigma_1(ij),B=\sum_{i=1}^ni\cdot\sigma_1(i^2) ,则 A n s = 2 A B Ans=2A-B

且有
A = i = 1 n i j = 1 i x i y j x j / y [ ( x , y ) = 1 ] = i = 1 n i j = 1 i x i y j x j / y d ( x , y ) μ ( d ) = d = 1 n μ ( d ) d x x x i i d y y j i j y = d = 1 n μ ( d ) x = 1 n d d x x i n d d i y = 1 n d y j i d j d y = d = 1 n μ ( d ) d 2 i = 1 n d i x i x y = 1 n d y j i y = d = 1 n μ ( d ) d 2 i = 1 n d i σ 1 ( i ) j = 1 i σ 1 ( j ) = d = 1 n μ ( d ) d 2 i = 1 n d i σ 1 ( i ) S σ 1 ( i ) \large \begin{aligned} A&=\sum_{i=1}^ni\cdot\sum_{j=1}^i\sum_{x|i}\sum_{y|j}x\cdot j/y[(x,y)=1]\\ &=\sum_{i=1}^ni\cdot\sum_{j=1}^i\sum_{x|i}\sum_{y|j}x\cdot j/y\sum_{d|(x,y)}\mu(d)\\ &=\sum_{d=1}^n\mu(d)\sum_{d|x}x\sum_{x|i}i\sum_{d|y}\sum_{y|j}^i\frac jy\\ &=\sum_{d=1}^n\mu(d)\sum_{x=1}^{\lfloor\frac nd\rfloor}dx\sum_{x|i}^{\lfloor\frac nd\rfloor}di\sum_{y=1}^{\lfloor\frac nd\rfloor}\sum_{y|j}^i\frac{dj}{dy}\\ &=\sum_{d=1}^n\mu(d)d^2\sum_{i=1}^{\lfloor\frac nd\rfloor}i\sum_{x|i}x\sum_{y=1}^{\lfloor\frac nd\rfloor}\sum_{y|j}^iy\\ &=\sum_{d=1}^n\mu(d)d^2\sum_{i=1}^{\lfloor\frac nd\rfloor}i\cdot\sigma_1(i)\sum_{j=1}^{i}\sigma_1(j)\\ &=\sum_{d=1}^n\mu(d)d^2\sum_{i=1}^{\lfloor\frac nd\rfloor}i\cdot\sigma_1(i)\cdot S_{\sigma_1}(i)\\\end{aligned}
B = i = 1 n i x i y i x i / y [ ( x , y ) = 1 ] = i = 1 n i x i y i x i / y d ( x , y ) μ ( d ) = d = 1 n μ ( d ) d i i d x i d y i x i y = d = 1 n μ ( d ) i = 1 n d d i x i y i d x d i d y = d = 1 n μ ( d ) d 2 i = 1 n d i x i x y i i y = d = 1 n μ ( d ) d 2 i = 1 n d i x i x y i y = d = 1 n μ ( d ) d 2 i = 1 n d i σ 1 ( i ) 2 \large \begin{aligned} B&=\sum_{i=1}^ni\sum_{x|i}\sum_{y|i}x\cdot i/y[(x,y)=1]\\ &=\sum_{i=1}^ni\cdot\sum_{x|i}\sum_{y|i}x\cdot i/y\sum_{d|(x,y)}\mu(d)\\ &=\sum_{d=1}^n\mu(d)\sum_{d|i}i\sum_{d|x|i}\sum_{d|y|i}x\cdot \frac iy\\ &=\sum_{d=1}^n\mu(d)\sum_{i=1}^{\lfloor\frac nd\rfloor}di\sum_{x|i}\sum_{y|i}dx\cdot \frac {di}{dy}\\ &=\sum_{d=1}^n\mu(d)d^2\sum_{i=1}^{\lfloor\frac nd\rfloor}i\sum_{x|i}x\sum_{y|i}\frac {i}{y}\\ &=\sum_{d=1}^n\mu(d)d^2\sum_{i=1}^{\lfloor\frac nd\rfloor}i\sum_{x|i}x\sum_{y|i}y\\ &=\sum_{d=1}^n\mu(d)d^2\sum_{i=1}^{\lfloor\frac nd\rfloor}i\sigma_1(i)^2\\ \end{aligned}
A n s = 2 A B = \large \begin{aligned} \therefore Ans=2A-B&= \end{aligned}
再次拖更…

猜你喜欢

转载自blog.csdn.net/Ike940067893/article/details/85042174