This article is made by Jason-Cow.
Welcome to reprint.
But please post the article's address.

莫比乌斯定理(未完待续......):

形式1:

Mobius反演定理-BZOJ2154-LMLPHP

形式2:

Mobius反演定理-BZOJ2154-LMLPHP

引理:

Mobius反演定理-BZOJ2154-LMLPHP

证明1:

      右边=Mobius反演定理-BZOJ2154-LMLPHP带入左边等式,得              

               Mobius反演定理-BZOJ2154-LMLPHP

      Mobius反演定理-BZOJ2154-LMLPHP

      Mobius反演定理-BZOJ2154-LMLPHP

      Mobius反演定理-BZOJ2154-LMLPHP    又Mobius反演定理-BZOJ2154-LMLPHPMobius反演定理-BZOJ2154-LMLPHP当且仅当 : Mobius反演定理-BZOJ2154-LMLPHP,即Mobius反演定理-BZOJ2154-LMLPHP时,上式非Mobius反演定理-BZOJ2154-LMLPHP

         Mobius反演定理-BZOJ2154-LMLPHP

   所以,Mobius反演定理-BZOJ2154-LMLPHP成立。

 bzoj2154

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

时间复杂度

Mobius反演定理-BZOJ2154-LMLPHP

 换元:令

Mobius反演定理-BZOJ2154-LMLPHP

/*

Mobius反演定理-BZOJ2154-LMLPHP

Mobius反演定理-BZOJ2154-LMLPHP

*/

Mobius反演定理-BZOJ2154-LMLPHP

此题的精髓就一个字,

 #include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout) const int mod=,maxn=1e7+;
int f[maxn],p[maxn],flag[maxn],cnt,S[maxn];
void init(int n,int m){
f[]=;
for(int i=;i<=n;i++) {
if(!flag[i])p[++cnt]=i,f[i]=(-i)%mod;
for(int j=;j<=cnt && i*p[j]<=n;j++) {
flag[i*p[j]]=;
if(i%p[j]==){f[i*p[j]]=f[i]%mod;break;}
f[i*p[j]]=((long long)(f[i]%mod)*(f[p[j]]%mod))%mod;
}
}
for(int i=;i<=m;i++)S[i]=((S[i]%mod)+((S[i-]+i)%mod))%mod;
} int main(){
int n,m;scanf("%d%d",&n,&m);if(n>m)swap(n,m);
init(n,m);
int ans=;
for(int Q=;Q<=n;Q++)
ans=(ans+(((Q%mod)*(long long)f[Q]*(((long long)S[n/Q]*S[m/Q])%mod))%mod)%mod)%mod;
printf("%d\n",(ans+mod)%mod);
return ;
}
f(n)=∑d|nμ(d)F(nd)=∑d|nμ(d)∑k|ndf(k)=∑k|nf(k)∑d|nkμ(d)
05-23 04:29