莫比乌斯函数模版
//莫比乌斯打表(phi可以删除)
//phi--欧拉函数表 miu--莫比乌斯函数表 fac--i最大的素因子辅助打phi表
int phi[maxn],miu[maxn],fac[maxn];
ll f[maxn], F[maxn];
void init()
{
for (int i = 1; i < maxn; ++i) fac[i] = i;
phi[1] = miu[1] = 1;
for (int i = 2; i < maxn; ++i)
{
if (fac[i] == i)
for (int j = i << 1; j < maxn; j += i)
fac[j] = i;
if (i / fac[i] % fac[i]) phi[i] = (fac[i] - 1)*phi[i / fac[i]], miu[i] = -miu[i / fac[i]]; //如果b质数 a%b!=0 phi(a*b) = phi(a)*b - phi(a)
else phi[i] = fac[i] * phi[i / fac[i]], miu[i] = 0; //当b是质数,a%b==0,phi(a*b)=phi(a)*b
}
}
//求一个数的欧拉函数值--复杂度n^1/2
int miu(ll n){
int prime = 1;
int flag = 0;
for (int i = 2; i*i <= n; i++) {
if (n%i == 0) {
prime++;
n /= i;
if (n%i == 0) {
flag = 1;
break;
}
}
}
if (flag)
return 0;
if (prime % 2)return -1;
else return 1;
}