bzoj2005 [Noi2010]能量采集（Mobius反演，欧拉函数）

x=1ny=1mgcd(x,y)$\sum\limits_{x=1}^n\sum\limits_{y=1}^mgcd(x,y)$可以容斥原理求O(nlogn)$O(nlogn)$

d=1nt|dμ(t)dtn/dm/d$\sum\limits_{d=1}^n\sum\limits_{t|d}\mu(t)\frac{d}{t}\lfloor n/d\rfloor\lfloor m/d\rfloor$
t|dμ(t)dt=ϕ(d)$\sum\limits_{t|d}\mu(t)\frac{d}{t}=\phi(d)$

#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define N 100010
inline char gc(){
static char buf[1<<16],*S,*T;
return *S++;
}
int x=0,f=1;char ch=gc();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=gc();
return x*f;
}
int n,m,prime[N/10],tot=0;ll phi[N],ans=0;
bool notprime[N];
inline void getphi(){
notprime[1]=1;phi[1]=1;
for(int i=2;i<=n;++i){
if(!notprime[i]) prime[++tot]=i,phi[i]=i-1;
for(int j=1;prime[j]*i<=n;++j){
notprime[prime[j]*i]=1;
if(i%prime[j]==0){phi[i*prime[j]]=phi[i]*prime[j];break;}
phi[i*prime[j]]=phi[i]*phi[prime[j]];
}
}for(int i=2;i<=n;++i) phi[i]+=phi[i-1];
}
int main(){
//  freopen("a.in","r",stdin);
}