const int maxn = 1e7 + 10;
LL phi[maxn];
LL p[maxn];
LL tot;
void Euler()
{
phi[1] = 1;
for (LL i = 2; i < maxn; i++)
{
if (!phi[i])
{
phi[i] = i - 1;
p[tot++] = i;
}
for (LL j = 0; j < tot && i*p[j] < maxn; j++)
{
if (i % p[j])
phi[i * p[j]] = phi[i] * (p[j] - 1);
else
{
phi[i * p[j]] = phi[i] * p[j];
break;
}
}
}
}
欧拉函数打表
最新推荐文章于 2021-10-04 20:52:13 发布