const int maxn=1e6;
const int mod=1e9+7;
bool Mark[MAXSIZE];
int prime[maxn];
bool vis[maxn];
int cnt = 0;
int mu[maxn];
int sum[maxn];
int g[maxn];
void Init()
{
memset(vis,0,sizeof(vis));
mu[1] = 1;
cnt = 0;
for(int i=2; i<maxn; i++)
{
if(!vis[i])
{
prime[cnt++] = i;
mu[i] = -1;
}
for(int j=0; j<cnt&&i*prime[j]<maxn; j++)
{
vis[i*prime[j]] = 1;
if(i%prime[j]) mu[i*prime[j]] = -mu[i];
else
{
mu[i*prime[j]] = 0;
break;
}
}
}
}
for (int i = 1; i <= n; i++)
g[i] = f[i];
for (int i = 1; i <= n; i++)
for (int j = i + i; j <= n; j += i)
g[j] -= g[i];
莫比乌斯函数模版
最新推荐文章于 2020-11-13 11:20:54 发布