# 【51nod1678】lyk与gcd（莫比乌斯反演+枚举因数）

### 莫比乌斯反演

$\sum_{j=1}^na_j[gcd(i,j)=1]$

$\sum_{j=1}^na_j\sum_{p|i,p|j}\mu(p)$

$\sum_{p|i}\mu(p)\sum_{j=1}^na_j[p|j]$

### 代码

#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 100000
#define IT vector<int>::iterator
#define pb push_back
using namespace std;
int n,a[N+5],s[N+5];vector<int> v[N+5];
class FastIO
{
private:
#define FS 100000
#define pc(c) (C==E&&(clear(),0),*C++=c)
#define tn (x<<3)+(x<<1)
#define D isdigit(c=tc())
int T;char c,*A,*B,*C,*E,FI[FS],FO[FS],S[FS];
public:
I FastIO() {A=B=FI,C=FO,E=FO+FS;}
Tp I void read(Ty& x) {x=0;W(!D);W(x=tn+(c&15),D);}
Tp I void write(Ty x) {W(S[++T]=x%10+48,x/=10);W(T) pc(S[T--]);}
Tp I void writeln(Con Ty& x) {write(x),pc('\n');}
I void clear() {fwrite(FO,1,C-FO,stdout),C=FO;}
}F;
class LinearSieve//线性筛预处理莫比乌斯函数
{
private:
int Pt,P[N+5],mu[N+5];
public:
I int operator [] (CI x) Con {return mu[x];}
I LinearSieve()
{
mu[1]=1;for(RI i=2,j;i<=N;++i)
for(!P[i]&&(mu[P[++Pt]=i]=-1),j=1;j<=Pt&&1LL*i*P[j]<=N;++j)
if(P[i*P[j]]=1,i%P[j]) mu[i*P[j]]=-mu[i];else break;
}
}L;
int main()
{