[bzoj2693]jzptab
Posted al-ca
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了[bzoj2693]jzptab相关的知识,希望对你有一定的参考价值。
又没推出来……
不过通过这道题还是学到好多东西呢,比如积性函数,线筛什么的。
$\sum \limits _i=1^n \sum \limits _j=1^m lcm(i,j)$
=$\sum \limits _d=1^min(n,m) \sum \limits _i=1^\left \lfloor \fracnd \right \rfloor \sum \limits _j=1^\left \lfloor \fracmd \right \rfloor i*j*d \left [ gcd(i,j)=1 \right ]$
=$\sum \limits _d=1^min(n,m) \sum \limits _i=1^\left \lfloor \fracnd \right \rfloor \sum \limits _j=1^\left \lfloor \fracmd \right \rfloor \left ( i*j*d *\sum \limits _t\mid gcd(i,j)u(t) \right )$
=$\sum \limits _d=1^min(n,m) d* \sum \limits _i=1^\left \lfloor \fracnd \right \rfloor \sum \limits _j=1^\left \lfloor \fracmd \right \rfloor \left ( i*j *\sum \limits _t\mid gcd(i,j)u(t) \right )$
=$\sum \limits _d=1^min(n,m) d* \sum \limits _t=1^min\left ( \left \lfloor \fracnd \right \rfloor \left \lfloor \fracmd \right \rfloor\right ) u(t) * t^2 *\sum \limits _i=1^\left \lfloor \fracnd*t \right \rfloor \sum \limits _j=1^\left \lfloor \fracmd*t \right \rfloor i*j$
自己推到这就又不会了……
主要是没想到这玩意:$\sum \limits _i \sum \limits _j \left ( i*j \right )= \sum \limits _i \left ( i*\sum \limits _j j\right ) = \left ( \sum \limits _ii \right )*\left ( \sum \limits _jj \right )$
于是原式=$\sum \limits _d=1^min(n,m) \sum \limits _t=1^min\left ( \left \lfloor \fracnd \right \rfloor ,\left \lfloor \fracmd \right \rfloor \right ) u(t) * t^2 *\left ( \sum \limits _i=1^\left \lfloor \fracnd*t \right \rfloori \right ) * \left ( \sum \limits _j=1^\left \lfloor \fracmd*t \right \rfloorj \right )$
后面是一个等差数列,原式=$\sum \limits _d=1^min(n,m) d* \left ( \sum \limits _t=1^min\left ( \left \lfloor \fracnd \right \rfloor \left \lfloor \fracmd \right \rfloor \right ) u(t)*t^2 *\frac\left \lfloor \fracnd*t \right \rfloor *\left ( \left \lfloor \fracnd*t \right \rfloor +1 \right ) * \left \lfloor \fracmd*t \right \rfloor \left ( \left \lfloor \fracmd*t \right \rfloor +1 \right )4 \right )$
令T=d*t,原式=$\sum \limits _T=1^min(n,m) \frac\left \lfloor \fracnT \right \rfloor * \left ( \left \lfloor \fracmT \right \rfloor +1 \right ) * \left \lfloor \fracmT \right \rfloor * \left ( \left \lfloor \fracmT \right \rfloor +1 \right )4 * T*\sum \limits _t\mid Tu(t)*t $
到这里式子就推完了(稍恶心),之后设$f(n)=n*\sum \limits _t\mid n u(t)*t$,通过一些我看不懂的证明可以发现它是积性函数,于是我们可以用线筛搞出来它,前面的部分整除分块就可以了。
1 #include<iostream> 2 #include<cstring> 3 #include<cstdio> 4 #define int LL 5 #define LL long long 6 using namespace std; 7 const int mod=100000009; 8 bool noprime[12000000]; 9 int prime[12000000],cnt; 10 int low[12000000],f[12000000],mu[12000000]; 11 void shai(int n) 12 13 f[1]=mu[1]=1; 14 for(int i=2;i<=n;i++) 15 16 if(!noprime[i]) prime[++cnt]=i,mu[i]=-1,f[i]=-i+1+mod; 17 for(int j=1;j<=cnt&&prime[j]*i<=n;j++) 18 19 noprime[prime[j]*i]=1; 20 if(i%prime[j]==0)f[i*prime[j]]=f[i];break; 21 f[i*prime[j]]=(f[i]*f[prime[j]])%mod;mu[i*prime[j]]=-mu[i]; 22 23 24 for(int i=1;i<=n;i++)f[i]=f[i]*i%mod; 25 for(int i=1;i<=n;i++)f[i]=(f[i]+f[i-1])%mod; 26 27 LL get(LL x)return (x*(x+1)/2)%mod; 28 int T,n,m; 29 signed main() 30 31 shai(12000000); 32 cin>>T; 33 while(T--) 34 35 cin>>n>>m;if(n>m)swap(n,m); 36 LL ans=0; 37 for(int l=1,r;l<=n;l=r+1) 38 39 r=min(n/(n/l),m/(m/l)); 40 ans=(ans+get(n/l)*get(m/l)%mod*((f[r]-f[l-1]+mod)%mod)%mod)%mod; 41 42 printf("%lld\n",(ans%mod+mod)%mod); 43 44
以上是关于[bzoj2693]jzptab的主要内容,如果未能解决你的问题,请参考以下文章