![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
bool vis[maxn]; int prime[maxn]; int Mob[maxn]; void Mobius_sieve(){ int cnt = 0; vis[1] = 1; Mob[1] = 1; for(int i = 2; i <= maxn; i++){ if(!vis[i]) prime[cnt++] = i, Mob[i] = - 1; for(int j = 0; j < cnt && 1LL * prime[j] * i <= maxn; j++){ vis[prime[j] * i] = 1; Mob[i * prime[j]] = (i % prime[j] ? -Mob[i]: 0); if(i % prime[j] == 0) break; } } }